babylon.d.txt 2.8 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925
  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 Vector3 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. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5217. */
  5218. export class PerformanceMonitor {
  5219. private _enabled;
  5220. private _rollingFrameTime;
  5221. private _lastFrameTimeMs;
  5222. /**
  5223. * constructor
  5224. * @param frameSampleSize The number of samples required to saturate the sliding window
  5225. */
  5226. constructor(frameSampleSize?: number);
  5227. /**
  5228. * Samples current frame
  5229. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5230. */
  5231. sampleFrame(timeMs?: number): void;
  5232. /**
  5233. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5234. */
  5235. readonly averageFrameTime: number;
  5236. /**
  5237. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5238. */
  5239. readonly averageFrameTimeVariance: number;
  5240. /**
  5241. * Returns the frame time of the most recent frame
  5242. */
  5243. readonly instantaneousFrameTime: number;
  5244. /**
  5245. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5246. */
  5247. readonly averageFPS: number;
  5248. /**
  5249. * Returns the average framerate in frames per second using the most recent frame time
  5250. */
  5251. readonly instantaneousFPS: number;
  5252. /**
  5253. * Returns true if enough samples have been taken to completely fill the sliding window
  5254. */
  5255. readonly isSaturated: boolean;
  5256. /**
  5257. * Enables contributions to the sliding window sample set
  5258. */
  5259. enable(): void;
  5260. /**
  5261. * Disables contributions to the sliding window sample set
  5262. * Samples will not be interpolated over the disabled period
  5263. */
  5264. disable(): void;
  5265. /**
  5266. * Returns true if sampling is enabled
  5267. */
  5268. readonly isEnabled: boolean;
  5269. /**
  5270. * Resets performance monitor
  5271. */
  5272. reset(): void;
  5273. }
  5274. /**
  5275. * RollingAverage
  5276. *
  5277. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5278. */
  5279. export class RollingAverage {
  5280. /**
  5281. * Current average
  5282. */
  5283. average: number;
  5284. /**
  5285. * Current variance
  5286. */
  5287. variance: number;
  5288. protected _samples: Array<number>;
  5289. protected _sampleCount: number;
  5290. protected _pos: number;
  5291. protected _m2: number;
  5292. /**
  5293. * constructor
  5294. * @param length The number of samples required to saturate the sliding window
  5295. */
  5296. constructor(length: number);
  5297. /**
  5298. * Adds a sample to the sample set
  5299. * @param v The sample value
  5300. */
  5301. add(v: number): void;
  5302. /**
  5303. * Returns previously added values or null if outside of history or outside the sliding window domain
  5304. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5305. * @return Value previously recorded with add() or null if outside of range
  5306. */
  5307. history(i: number): number;
  5308. /**
  5309. * Returns true if enough samples have been taken to completely fill the sliding window
  5310. * @return true if sample-set saturated
  5311. */
  5312. isSaturated(): boolean;
  5313. /**
  5314. * Resets the rolling average (equivalent to 0 samples taken so far)
  5315. */
  5316. reset(): void;
  5317. /**
  5318. * Wraps a value around the sample range boundaries
  5319. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5320. * @return Wrapped position in sample range
  5321. */
  5322. protected _wrapPosition(i: number): number;
  5323. }
  5324. }
  5325. declare module BABYLON {
  5326. /**
  5327. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5328. * The underlying implementation relies on an associative array to ensure the best performances.
  5329. * The value can be anything including 'null' but except 'undefined'
  5330. */
  5331. export class StringDictionary<T> {
  5332. /**
  5333. * This will clear this dictionary and copy the content from the 'source' one.
  5334. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5335. * @param source the dictionary to take the content from and copy to this dictionary
  5336. */
  5337. copyFrom(source: StringDictionary<T>): void;
  5338. /**
  5339. * Get a value based from its key
  5340. * @param key the given key to get the matching value from
  5341. * @return the value if found, otherwise undefined is returned
  5342. */
  5343. get(key: string): T | undefined;
  5344. /**
  5345. * Get a value from its key or add it if it doesn't exist.
  5346. * This method will ensure you that a given key/data will be present in the dictionary.
  5347. * @param key the given key to get the matching value from
  5348. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5349. * The factory will only be invoked if there's no data for the given key.
  5350. * @return the value corresponding to the key.
  5351. */
  5352. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5353. /**
  5354. * Get a value from its key if present in the dictionary otherwise add it
  5355. * @param key the key to get the value from
  5356. * @param val if there's no such key/value pair in the dictionary add it with this value
  5357. * @return the value corresponding to the key
  5358. */
  5359. getOrAdd(key: string, val: T): T;
  5360. /**
  5361. * Check if there's a given key in the dictionary
  5362. * @param key the key to check for
  5363. * @return true if the key is present, false otherwise
  5364. */
  5365. contains(key: string): boolean;
  5366. /**
  5367. * Add a new key and its corresponding value
  5368. * @param key the key to add
  5369. * @param value the value corresponding to the key
  5370. * @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
  5371. */
  5372. add(key: string, value: T): boolean;
  5373. /**
  5374. * Update a specific value associated to a key
  5375. * @param key defines the key to use
  5376. * @param value defines the value to store
  5377. * @returns true if the value was updated (or false if the key was not found)
  5378. */
  5379. set(key: string, value: T): boolean;
  5380. /**
  5381. * Get the element of the given key and remove it from the dictionary
  5382. * @param key defines the key to search
  5383. * @returns the value associated with the key or null if not found
  5384. */
  5385. getAndRemove(key: string): Nullable<T>;
  5386. /**
  5387. * Remove a key/value from the dictionary.
  5388. * @param key the key to remove
  5389. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5390. */
  5391. remove(key: string): boolean;
  5392. /**
  5393. * Clear the whole content of the dictionary
  5394. */
  5395. clear(): void;
  5396. /**
  5397. * Gets the current count
  5398. */
  5399. readonly count: number;
  5400. /**
  5401. * Execute a callback on each key/val of the dictionary.
  5402. * Note that you can remove any element in this dictionary in the callback implementation
  5403. * @param callback the callback to execute on a given key/value pair
  5404. */
  5405. forEach(callback: (key: string, val: T) => void): void;
  5406. /**
  5407. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5408. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5409. * Note that you can remove any element in this dictionary in the callback implementation
  5410. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5411. * @returns the first item
  5412. */
  5413. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5414. private _count;
  5415. private _data;
  5416. }
  5417. }
  5418. declare module BABYLON {
  5419. /**
  5420. * Helper class that provides a small promise polyfill
  5421. */
  5422. export class PromisePolyfill {
  5423. /**
  5424. * Static function used to check if the polyfill is required
  5425. * If this is the case then the function will inject the polyfill to window.Promise
  5426. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5427. */
  5428. static Apply(force?: boolean): void;
  5429. }
  5430. }
  5431. declare module BABYLON {
  5432. /**
  5433. * Class used to store data that will be store in GPU memory
  5434. */
  5435. export class Buffer {
  5436. private _engine;
  5437. private _buffer;
  5438. /** @hidden */ data: Nullable<DataArray>;
  5439. private _updatable;
  5440. private _instanced;
  5441. /**
  5442. * Gets the byte stride.
  5443. */
  5444. readonly byteStride: number;
  5445. /**
  5446. * Constructor
  5447. * @param engine the engine
  5448. * @param data the data to use for this buffer
  5449. * @param updatable whether the data is updatable
  5450. * @param stride the stride (optional)
  5451. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5452. * @param instanced whether the buffer is instanced (optional)
  5453. * @param useBytes set to true if the stride in in bytes (optional)
  5454. */
  5455. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5456. /**
  5457. * Create a new VertexBuffer based on the current buffer
  5458. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5459. * @param offset defines offset in the buffer (0 by default)
  5460. * @param size defines the size in floats of attributes (position is 3 for instance)
  5461. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5462. * @param instanced defines if the vertex buffer contains indexed data
  5463. * @param useBytes defines if the offset and stride are in bytes
  5464. * @returns the new vertex buffer
  5465. */
  5466. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5467. /**
  5468. * Gets a boolean indicating if the Buffer is updatable?
  5469. * @returns true if the buffer is updatable
  5470. */
  5471. isUpdatable(): boolean;
  5472. /**
  5473. * Gets current buffer's data
  5474. * @returns a DataArray or null
  5475. */
  5476. getData(): Nullable<DataArray>;
  5477. /**
  5478. * Gets underlying native buffer
  5479. * @returns underlying native buffer
  5480. */
  5481. getBuffer(): Nullable<WebGLBuffer>;
  5482. /**
  5483. * Gets the stride in float32 units (i.e. byte stride / 4).
  5484. * May not be an integer if the byte stride is not divisible by 4.
  5485. * DEPRECATED. Use byteStride instead.
  5486. * @returns the stride in float32 units
  5487. */
  5488. getStrideSize(): number;
  5489. /**
  5490. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5491. * @param data defines the data to store
  5492. */
  5493. create(data?: Nullable<DataArray>): void;
  5494. /** @hidden */ rebuild(): void;
  5495. /**
  5496. * Update current buffer data
  5497. * @param data defines the data to store
  5498. */
  5499. update(data: DataArray): void;
  5500. /**
  5501. * Updates the data directly.
  5502. * @param data the new data
  5503. * @param offset the new offset
  5504. * @param vertexCount the vertex count (optional)
  5505. * @param useBytes set to true if the offset is in bytes
  5506. */
  5507. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5508. /**
  5509. * Release all resources
  5510. */
  5511. dispose(): void;
  5512. }
  5513. /**
  5514. * Specialized buffer used to store vertex data
  5515. */
  5516. export class VertexBuffer {
  5517. /** @hidden */ buffer: Buffer;
  5518. private _kind;
  5519. private _size;
  5520. private _ownsBuffer;
  5521. private _instanced;
  5522. private _instanceDivisor;
  5523. /**
  5524. * The byte type.
  5525. */
  5526. static readonly BYTE: number;
  5527. /**
  5528. * The unsigned byte type.
  5529. */
  5530. static readonly UNSIGNED_BYTE: number;
  5531. /**
  5532. * The short type.
  5533. */
  5534. static readonly SHORT: number;
  5535. /**
  5536. * The unsigned short type.
  5537. */
  5538. static readonly UNSIGNED_SHORT: number;
  5539. /**
  5540. * The integer type.
  5541. */
  5542. static readonly INT: number;
  5543. /**
  5544. * The unsigned integer type.
  5545. */
  5546. static readonly UNSIGNED_INT: number;
  5547. /**
  5548. * The float type.
  5549. */
  5550. static readonly FLOAT: number;
  5551. /**
  5552. * Gets or sets the instance divisor when in instanced mode
  5553. */
  5554. instanceDivisor: number;
  5555. /**
  5556. * Gets the byte stride.
  5557. */
  5558. readonly byteStride: number;
  5559. /**
  5560. * Gets the byte offset.
  5561. */
  5562. readonly byteOffset: number;
  5563. /**
  5564. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5565. */
  5566. readonly normalized: boolean;
  5567. /**
  5568. * Gets the data type of each component in the array.
  5569. */
  5570. readonly type: number;
  5571. /**
  5572. * Constructor
  5573. * @param engine the engine
  5574. * @param data the data to use for this vertex buffer
  5575. * @param kind the vertex buffer kind
  5576. * @param updatable whether the data is updatable
  5577. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5578. * @param stride the stride (optional)
  5579. * @param instanced whether the buffer is instanced (optional)
  5580. * @param offset the offset of the data (optional)
  5581. * @param size the number of components (optional)
  5582. * @param type the type of the component (optional)
  5583. * @param normalized whether the data contains normalized data (optional)
  5584. * @param useBytes set to true if stride and offset are in bytes (optional)
  5585. */
  5586. 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);
  5587. /** @hidden */ rebuild(): void;
  5588. /**
  5589. * Returns the kind of the VertexBuffer (string)
  5590. * @returns a string
  5591. */
  5592. getKind(): string;
  5593. /**
  5594. * Gets a boolean indicating if the VertexBuffer is updatable?
  5595. * @returns true if the buffer is updatable
  5596. */
  5597. isUpdatable(): boolean;
  5598. /**
  5599. * Gets current buffer's data
  5600. * @returns a DataArray or null
  5601. */
  5602. getData(): Nullable<DataArray>;
  5603. /**
  5604. * Gets underlying native buffer
  5605. * @returns underlying native buffer
  5606. */
  5607. getBuffer(): Nullable<WebGLBuffer>;
  5608. /**
  5609. * Gets the stride in float32 units (i.e. byte stride / 4).
  5610. * May not be an integer if the byte stride is not divisible by 4.
  5611. * DEPRECATED. Use byteStride instead.
  5612. * @returns the stride in float32 units
  5613. */
  5614. getStrideSize(): number;
  5615. /**
  5616. * Returns the offset as a multiple of the type byte length.
  5617. * DEPRECATED. Use byteOffset instead.
  5618. * @returns the offset in bytes
  5619. */
  5620. getOffset(): number;
  5621. /**
  5622. * Returns the number of components per vertex attribute (integer)
  5623. * @returns the size in float
  5624. */
  5625. getSize(): number;
  5626. /**
  5627. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5628. * @returns true if this buffer is instanced
  5629. */
  5630. getIsInstanced(): boolean;
  5631. /**
  5632. * Returns the instancing divisor, zero for non-instanced (integer).
  5633. * @returns a number
  5634. */
  5635. getInstanceDivisor(): number;
  5636. /**
  5637. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5638. * @param data defines the data to store
  5639. */
  5640. create(data?: DataArray): void;
  5641. /**
  5642. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5643. * This function will create a new buffer if the current one is not updatable
  5644. * @param data defines the data to store
  5645. */
  5646. update(data: DataArray): void;
  5647. /**
  5648. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5649. * Returns the directly updated WebGLBuffer.
  5650. * @param data the new data
  5651. * @param offset the new offset
  5652. * @param useBytes set to true if the offset is in bytes
  5653. */
  5654. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5655. /**
  5656. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5657. */
  5658. dispose(): void;
  5659. /**
  5660. * Enumerates each value of this vertex buffer as numbers.
  5661. * @param count the number of values to enumerate
  5662. * @param callback the callback function called for each value
  5663. */
  5664. forEach(count: number, callback: (value: number, index: number) => void): void;
  5665. /**
  5666. * Positions
  5667. */
  5668. static readonly PositionKind: string;
  5669. /**
  5670. * Normals
  5671. */
  5672. static readonly NormalKind: string;
  5673. /**
  5674. * Tangents
  5675. */
  5676. static readonly TangentKind: string;
  5677. /**
  5678. * Texture coordinates
  5679. */
  5680. static readonly UVKind: string;
  5681. /**
  5682. * Texture coordinates 2
  5683. */
  5684. static readonly UV2Kind: string;
  5685. /**
  5686. * Texture coordinates 3
  5687. */
  5688. static readonly UV3Kind: string;
  5689. /**
  5690. * Texture coordinates 4
  5691. */
  5692. static readonly UV4Kind: string;
  5693. /**
  5694. * Texture coordinates 5
  5695. */
  5696. static readonly UV5Kind: string;
  5697. /**
  5698. * Texture coordinates 6
  5699. */
  5700. static readonly UV6Kind: string;
  5701. /**
  5702. * Colors
  5703. */
  5704. static readonly ColorKind: string;
  5705. /**
  5706. * Matrix indices (for bones)
  5707. */
  5708. static readonly MatricesIndicesKind: string;
  5709. /**
  5710. * Matrix weights (for bones)
  5711. */
  5712. static readonly MatricesWeightsKind: string;
  5713. /**
  5714. * Additional matrix indices (for bones)
  5715. */
  5716. static readonly MatricesIndicesExtraKind: string;
  5717. /**
  5718. * Additional matrix weights (for bones)
  5719. */
  5720. static readonly MatricesWeightsExtraKind: string;
  5721. /**
  5722. * Deduces the stride given a kind.
  5723. * @param kind The kind string to deduce
  5724. * @returns The deduced stride
  5725. */
  5726. static DeduceStride(kind: string): number;
  5727. /**
  5728. * Gets the byte length of the given type.
  5729. * @param type the type
  5730. * @returns the number of bytes
  5731. */
  5732. static GetTypeByteLength(type: number): number;
  5733. /**
  5734. * Enumerates each value of the given parameters as numbers.
  5735. * @param data the data to enumerate
  5736. * @param byteOffset the byte offset of the data
  5737. * @param byteStride the byte stride of the data
  5738. * @param componentCount the number of components per element
  5739. * @param componentType the type of the component
  5740. * @param count the total number of components
  5741. * @param normalized whether the data is normalized
  5742. * @param callback the callback function called for each value
  5743. */
  5744. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5745. private static _GetFloatValue;
  5746. }
  5747. }
  5748. declare module BABYLON {
  5749. /**
  5750. * Class representing spherical polynomial coefficients to the 3rd degree
  5751. */
  5752. export class SphericalPolynomial {
  5753. /**
  5754. * The x coefficients of the spherical polynomial
  5755. */
  5756. x: Vector3;
  5757. /**
  5758. * The y coefficients of the spherical polynomial
  5759. */
  5760. y: Vector3;
  5761. /**
  5762. * The z coefficients of the spherical polynomial
  5763. */
  5764. z: Vector3;
  5765. /**
  5766. * The xx coefficients of the spherical polynomial
  5767. */
  5768. xx: Vector3;
  5769. /**
  5770. * The yy coefficients of the spherical polynomial
  5771. */
  5772. yy: Vector3;
  5773. /**
  5774. * The zz coefficients of the spherical polynomial
  5775. */
  5776. zz: Vector3;
  5777. /**
  5778. * The xy coefficients of the spherical polynomial
  5779. */
  5780. xy: Vector3;
  5781. /**
  5782. * The yz coefficients of the spherical polynomial
  5783. */
  5784. yz: Vector3;
  5785. /**
  5786. * The zx coefficients of the spherical polynomial
  5787. */
  5788. zx: Vector3;
  5789. /**
  5790. * Adds an ambient color to the spherical polynomial
  5791. * @param color the color to add
  5792. */
  5793. addAmbient(color: Color3): void;
  5794. /**
  5795. * Scales the spherical polynomial by the given amount
  5796. * @param scale the amount to scale
  5797. */
  5798. scale(scale: number): void;
  5799. /**
  5800. * Gets the spherical polynomial from harmonics
  5801. * @param harmonics the spherical harmonics
  5802. * @returns the spherical polynomial
  5803. */
  5804. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5805. /**
  5806. * Constructs a spherical polynomial from an array.
  5807. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5808. * @returns the spherical polynomial
  5809. */
  5810. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5811. }
  5812. /**
  5813. * Class representing spherical harmonics coefficients to the 3rd degree
  5814. */
  5815. export class SphericalHarmonics {
  5816. /**
  5817. * The l0,0 coefficients of the spherical harmonics
  5818. */
  5819. l00: Vector3;
  5820. /**
  5821. * The l1,-1 coefficients of the spherical harmonics
  5822. */
  5823. l1_1: Vector3;
  5824. /**
  5825. * The l1,0 coefficients of the spherical harmonics
  5826. */
  5827. l10: Vector3;
  5828. /**
  5829. * The l1,1 coefficients of the spherical harmonics
  5830. */
  5831. l11: Vector3;
  5832. /**
  5833. * The l2,-2 coefficients of the spherical harmonics
  5834. */
  5835. l2_2: Vector3;
  5836. /**
  5837. * The l2,-1 coefficients of the spherical harmonics
  5838. */
  5839. l2_1: Vector3;
  5840. /**
  5841. * The l2,0 coefficients of the spherical harmonics
  5842. */
  5843. l20: Vector3;
  5844. /**
  5845. * The l2,1 coefficients of the spherical harmonics
  5846. */
  5847. l21: Vector3;
  5848. /**
  5849. * The l2,2 coefficients of the spherical harmonics
  5850. */
  5851. lL22: Vector3;
  5852. /**
  5853. * Adds a light to the spherical harmonics
  5854. * @param direction the direction of the light
  5855. * @param color the color of the light
  5856. * @param deltaSolidAngle the delta solid angle of the light
  5857. */
  5858. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5859. /**
  5860. * Scales the spherical harmonics by the given amount
  5861. * @param scale the amount to scale
  5862. */
  5863. scale(scale: number): void;
  5864. /**
  5865. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5866. *
  5867. * ```
  5868. * E_lm = A_l * L_lm
  5869. * ```
  5870. *
  5871. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5872. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5873. * the scaling factors are given in equation 9.
  5874. */
  5875. convertIncidentRadianceToIrradiance(): void;
  5876. /**
  5877. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5878. *
  5879. * ```
  5880. * L = (1/pi) * E * rho
  5881. * ```
  5882. *
  5883. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5884. */
  5885. convertIrradianceToLambertianRadiance(): void;
  5886. /**
  5887. * Gets the spherical harmonics from polynomial
  5888. * @param polynomial the spherical polynomial
  5889. * @returns the spherical harmonics
  5890. */
  5891. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5892. /**
  5893. * Constructs a spherical harmonics from an array.
  5894. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5895. * @returns the spherical harmonics
  5896. */
  5897. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5898. }
  5899. }
  5900. declare module BABYLON {
  5901. /**
  5902. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5903. */
  5904. export interface CubeMapInfo {
  5905. /**
  5906. * The pixel array for the front face.
  5907. * This is stored in format, left to right, up to down format.
  5908. */
  5909. front: Nullable<ArrayBufferView>;
  5910. /**
  5911. * The pixel array for the back face.
  5912. * This is stored in format, left to right, up to down format.
  5913. */
  5914. back: Nullable<ArrayBufferView>;
  5915. /**
  5916. * The pixel array for the left face.
  5917. * This is stored in format, left to right, up to down format.
  5918. */
  5919. left: Nullable<ArrayBufferView>;
  5920. /**
  5921. * The pixel array for the right face.
  5922. * This is stored in format, left to right, up to down format.
  5923. */
  5924. right: Nullable<ArrayBufferView>;
  5925. /**
  5926. * The pixel array for the up face.
  5927. * This is stored in format, left to right, up to down format.
  5928. */
  5929. up: Nullable<ArrayBufferView>;
  5930. /**
  5931. * The pixel array for the down face.
  5932. * This is stored in format, left to right, up to down format.
  5933. */
  5934. down: Nullable<ArrayBufferView>;
  5935. /**
  5936. * The size of the cubemap stored.
  5937. *
  5938. * Each faces will be size * size pixels.
  5939. */
  5940. size: number;
  5941. /**
  5942. * The format of the texture.
  5943. *
  5944. * RGBA, RGB.
  5945. */
  5946. format: number;
  5947. /**
  5948. * The type of the texture data.
  5949. *
  5950. * UNSIGNED_INT, FLOAT.
  5951. */
  5952. type: number;
  5953. /**
  5954. * Specifies whether the texture is in gamma space.
  5955. */
  5956. gammaSpace: boolean;
  5957. }
  5958. /**
  5959. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5960. */
  5961. export class PanoramaToCubeMapTools {
  5962. private static FACE_FRONT;
  5963. private static FACE_BACK;
  5964. private static FACE_RIGHT;
  5965. private static FACE_LEFT;
  5966. private static FACE_DOWN;
  5967. private static FACE_UP;
  5968. /**
  5969. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5970. *
  5971. * @param float32Array The source data.
  5972. * @param inputWidth The width of the input panorama.
  5973. * @param inputHeight The height of the input panorama.
  5974. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5975. * @return The cubemap data
  5976. */
  5977. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5978. private static CreateCubemapTexture;
  5979. private static CalcProjectionSpherical;
  5980. }
  5981. }
  5982. declare module BABYLON {
  5983. /**
  5984. * Helper class dealing with the extraction of spherical polynomial dataArray
  5985. * from a cube map.
  5986. */
  5987. export class CubeMapToSphericalPolynomialTools {
  5988. private static FileFaces;
  5989. /**
  5990. * Converts a texture to the according Spherical Polynomial data.
  5991. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5992. *
  5993. * @param texture The texture to extract the information from.
  5994. * @return The Spherical Polynomial data.
  5995. */
  5996. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  5997. /**
  5998. * Converts a cubemap to the according Spherical Polynomial data.
  5999. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6000. *
  6001. * @param cubeInfo The Cube map to extract the information from.
  6002. * @return The Spherical Polynomial data.
  6003. */
  6004. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6005. }
  6006. }
  6007. declare module BABYLON {
  6008. /**
  6009. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6010. * during the life time of the application.
  6011. */
  6012. export class EngineStore {
  6013. /** Gets the list of created engines */
  6014. static Instances: Engine[];
  6015. /**
  6016. * Gets the latest created engine
  6017. */
  6018. static readonly LastCreatedEngine: Nullable<Engine>;
  6019. /**
  6020. * Gets the latest created scene
  6021. */
  6022. static readonly LastCreatedScene: Nullable<Scene>;
  6023. }
  6024. }
  6025. declare module BABYLON {
  6026. /**
  6027. * Define options used to create a render target texture
  6028. */
  6029. export class RenderTargetCreationOptions {
  6030. /**
  6031. * Specifies is mipmaps must be generated
  6032. */
  6033. generateMipMaps?: boolean;
  6034. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6035. generateDepthBuffer?: boolean;
  6036. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6037. generateStencilBuffer?: boolean;
  6038. /** Defines texture type (int by default) */
  6039. type?: number;
  6040. /** Defines sampling mode (trilinear by default) */
  6041. samplingMode?: number;
  6042. /** Defines format (RGBA by default) */
  6043. format?: number;
  6044. }
  6045. }
  6046. declare module BABYLON {
  6047. /**
  6048. * @hidden
  6049. **/
  6050. export class _AlphaState {
  6051. private _isAlphaBlendDirty;
  6052. private _isBlendFunctionParametersDirty;
  6053. private _isBlendEquationParametersDirty;
  6054. private _isBlendConstantsDirty;
  6055. private _alphaBlend;
  6056. private _blendFunctionParameters;
  6057. private _blendEquationParameters;
  6058. private _blendConstants;
  6059. /**
  6060. * Initializes the state.
  6061. */
  6062. constructor();
  6063. readonly isDirty: boolean;
  6064. alphaBlend: boolean;
  6065. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6066. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6067. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6068. reset(): void;
  6069. apply(gl: WebGLRenderingContext): void;
  6070. }
  6071. }
  6072. declare module BABYLON {
  6073. /**
  6074. * @hidden
  6075. **/
  6076. export class _DepthCullingState {
  6077. private _isDepthTestDirty;
  6078. private _isDepthMaskDirty;
  6079. private _isDepthFuncDirty;
  6080. private _isCullFaceDirty;
  6081. private _isCullDirty;
  6082. private _isZOffsetDirty;
  6083. private _isFrontFaceDirty;
  6084. private _depthTest;
  6085. private _depthMask;
  6086. private _depthFunc;
  6087. private _cull;
  6088. private _cullFace;
  6089. private _zOffset;
  6090. private _frontFace;
  6091. /**
  6092. * Initializes the state.
  6093. */
  6094. constructor();
  6095. readonly isDirty: boolean;
  6096. zOffset: number;
  6097. cullFace: Nullable<number>;
  6098. cull: Nullable<boolean>;
  6099. depthFunc: Nullable<number>;
  6100. depthMask: boolean;
  6101. depthTest: boolean;
  6102. frontFace: Nullable<number>;
  6103. reset(): void;
  6104. apply(gl: WebGLRenderingContext): void;
  6105. }
  6106. }
  6107. declare module BABYLON {
  6108. /**
  6109. * @hidden
  6110. **/
  6111. export class _StencilState {
  6112. /** 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 */
  6113. static readonly ALWAYS: number;
  6114. /** Passed to stencilOperation to specify that stencil value must be kept */
  6115. static readonly KEEP: number;
  6116. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6117. static readonly REPLACE: number;
  6118. private _isStencilTestDirty;
  6119. private _isStencilMaskDirty;
  6120. private _isStencilFuncDirty;
  6121. private _isStencilOpDirty;
  6122. private _stencilTest;
  6123. private _stencilMask;
  6124. private _stencilFunc;
  6125. private _stencilFuncRef;
  6126. private _stencilFuncMask;
  6127. private _stencilOpStencilFail;
  6128. private _stencilOpDepthFail;
  6129. private _stencilOpStencilDepthPass;
  6130. readonly isDirty: boolean;
  6131. stencilFunc: number;
  6132. stencilFuncRef: number;
  6133. stencilFuncMask: number;
  6134. stencilOpStencilFail: number;
  6135. stencilOpDepthFail: number;
  6136. stencilOpStencilDepthPass: number;
  6137. stencilMask: number;
  6138. stencilTest: boolean;
  6139. constructor();
  6140. reset(): void;
  6141. apply(gl: WebGLRenderingContext): void;
  6142. }
  6143. }
  6144. declare module BABYLON {
  6145. /**
  6146. * @hidden
  6147. **/
  6148. export class _TimeToken { startTimeQuery: Nullable<WebGLQuery>; endTimeQuery: Nullable<WebGLQuery>; timeElapsedQuery: Nullable<WebGLQuery>; timeElapsedQueryEnded: boolean;
  6149. }
  6150. }
  6151. declare module BABYLON {
  6152. /**
  6153. * Class used to store data associated with WebGL texture data for the engine
  6154. * This class should not be used directly
  6155. */
  6156. export class InternalTexture {
  6157. /** hidden */ private static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6158. /**
  6159. * The source of the texture data is unknown
  6160. */
  6161. static DATASOURCE_UNKNOWN: number;
  6162. /**
  6163. * Texture data comes from an URL
  6164. */
  6165. static DATASOURCE_URL: number;
  6166. /**
  6167. * Texture data is only used for temporary storage
  6168. */
  6169. static DATASOURCE_TEMP: number;
  6170. /**
  6171. * Texture data comes from raw data (ArrayBuffer)
  6172. */
  6173. static DATASOURCE_RAW: number;
  6174. /**
  6175. * Texture content is dynamic (video or dynamic texture)
  6176. */
  6177. static DATASOURCE_DYNAMIC: number;
  6178. /**
  6179. * Texture content is generated by rendering to it
  6180. */
  6181. static DATASOURCE_RENDERTARGET: number;
  6182. /**
  6183. * Texture content is part of a multi render target process
  6184. */
  6185. static DATASOURCE_MULTIRENDERTARGET: number;
  6186. /**
  6187. * Texture data comes from a cube data file
  6188. */
  6189. static DATASOURCE_CUBE: number;
  6190. /**
  6191. * Texture data comes from a raw cube data
  6192. */
  6193. static DATASOURCE_CUBERAW: number;
  6194. /**
  6195. * Texture data come from a prefiltered cube data file
  6196. */
  6197. static DATASOURCE_CUBEPREFILTERED: number;
  6198. /**
  6199. * Texture content is raw 3D data
  6200. */
  6201. static DATASOURCE_RAW3D: number;
  6202. /**
  6203. * Texture content is a depth texture
  6204. */
  6205. static DATASOURCE_DEPTHTEXTURE: number;
  6206. /**
  6207. * Texture data comes from a raw cube data encoded with RGBD
  6208. */
  6209. static DATASOURCE_CUBERAW_RGBD: number;
  6210. /**
  6211. * Defines if the texture is ready
  6212. */
  6213. isReady: boolean;
  6214. /**
  6215. * Defines if the texture is a cube texture
  6216. */
  6217. isCube: boolean;
  6218. /**
  6219. * Defines if the texture contains 3D data
  6220. */
  6221. is3D: boolean;
  6222. /**
  6223. * Defines if the texture contains multiview data
  6224. */
  6225. isMultiview: boolean;
  6226. /**
  6227. * Gets the URL used to load this texture
  6228. */
  6229. url: string;
  6230. /**
  6231. * Gets the sampling mode of the texture
  6232. */
  6233. samplingMode: number;
  6234. /**
  6235. * Gets a boolean indicating if the texture needs mipmaps generation
  6236. */
  6237. generateMipMaps: boolean;
  6238. /**
  6239. * Gets the number of samples used by the texture (WebGL2+ only)
  6240. */
  6241. samples: number;
  6242. /**
  6243. * Gets the type of the texture (int, float...)
  6244. */
  6245. type: number;
  6246. /**
  6247. * Gets the format of the texture (RGB, RGBA...)
  6248. */
  6249. format: number;
  6250. /**
  6251. * Observable called when the texture is loaded
  6252. */
  6253. onLoadedObservable: Observable<InternalTexture>;
  6254. /**
  6255. * Gets the width of the texture
  6256. */
  6257. width: number;
  6258. /**
  6259. * Gets the height of the texture
  6260. */
  6261. height: number;
  6262. /**
  6263. * Gets the depth of the texture
  6264. */
  6265. depth: number;
  6266. /**
  6267. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6268. */
  6269. baseWidth: number;
  6270. /**
  6271. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6272. */
  6273. baseHeight: number;
  6274. /**
  6275. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6276. */
  6277. baseDepth: number;
  6278. /**
  6279. * Gets a boolean indicating if the texture is inverted on Y axis
  6280. */
  6281. invertY: boolean;
  6282. /** @hidden */ invertVScale: boolean;
  6283. /** @hidden */ associatedChannel: number;
  6284. /** @hidden */ dataSource: number;
  6285. /** @hidden */ buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6286. /** @hidden */ bufferView: Nullable<ArrayBufferView>;
  6287. /** @hidden */ bufferViewArray: Nullable<ArrayBufferView[]>;
  6288. /** @hidden */ bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6289. /** @hidden */ size: number;
  6290. /** @hidden */ extension: string;
  6291. /** @hidden */ files: Nullable<string[]>;
  6292. /** @hidden */ workingCanvas: HTMLCanvasElement;
  6293. /** @hidden */ workingContext: CanvasRenderingContext2D;
  6294. /** @hidden */ framebuffer: Nullable<WebGLFramebuffer>;
  6295. /** @hidden */ depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6296. /** @hidden */ MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6297. /** @hidden */ MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6298. /** @hidden */ attachments: Nullable<number[]>;
  6299. /** @hidden */ cachedCoordinatesMode: Nullable<number>;
  6300. /** @hidden */ cachedWrapU: Nullable<number>;
  6301. /** @hidden */ cachedWrapV: Nullable<number>;
  6302. /** @hidden */ cachedWrapR: Nullable<number>;
  6303. /** @hidden */ cachedAnisotropicFilteringLevel: Nullable<number>;
  6304. /** @hidden */ isDisabled: boolean;
  6305. /** @hidden */ compression: Nullable<string>;
  6306. /** @hidden */ generateStencilBuffer: boolean;
  6307. /** @hidden */ generateDepthBuffer: boolean;
  6308. /** @hidden */ comparisonFunction: number;
  6309. /** @hidden */ sphericalPolynomial: Nullable<SphericalPolynomial>;
  6310. /** @hidden */ lodGenerationScale: number;
  6311. /** @hidden */ lodGenerationOffset: number;
  6312. /** @hidden */ colorTextureArray: Nullable<WebGLTexture>;
  6313. /** @hidden */ depthStencilTextureArray: Nullable<WebGLTexture>;
  6314. /** @hidden */ lodTextureHigh: BaseTexture;
  6315. /** @hidden */ lodTextureMid: BaseTexture;
  6316. /** @hidden */ lodTextureLow: BaseTexture;
  6317. /** @hidden */ isRGBD: boolean;
  6318. /** @hidden */ webGLTexture: Nullable<WebGLTexture>;
  6319. /** @hidden */ references: number;
  6320. private _engine;
  6321. /**
  6322. * Gets the Engine the texture belongs to.
  6323. * @returns The babylon engine
  6324. */
  6325. getEngine(): Engine;
  6326. /**
  6327. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6328. */
  6329. readonly dataSource: number;
  6330. /**
  6331. * Creates a new InternalTexture
  6332. * @param engine defines the engine to use
  6333. * @param dataSource defines the type of data that will be used
  6334. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6335. */
  6336. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6337. /**
  6338. * Increments the number of references (ie. the number of Texture that point to it)
  6339. */
  6340. incrementReferences(): void;
  6341. /**
  6342. * Change the size of the texture (not the size of the content)
  6343. * @param width defines the new width
  6344. * @param height defines the new height
  6345. * @param depth defines the new depth (1 by default)
  6346. */
  6347. updateSize(width: int, height: int, depth?: int): void;
  6348. /** @hidden */ rebuild(): void;
  6349. /** @hidden */ swapAndDie(target: InternalTexture): void;
  6350. /**
  6351. * Dispose the current allocated resources
  6352. */
  6353. dispose(): void;
  6354. }
  6355. }
  6356. declare module BABYLON {
  6357. /**
  6358. * This represents the main contract an easing function should follow.
  6359. * Easing functions are used throughout the animation system.
  6360. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6361. */
  6362. export interface IEasingFunction {
  6363. /**
  6364. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6365. * of the easing function.
  6366. * The link below provides some of the most common examples of easing functions.
  6367. * @see https://easings.net/
  6368. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6369. * @returns the corresponding value on the curve defined by the easing function
  6370. */
  6371. ease(gradient: number): number;
  6372. }
  6373. /**
  6374. * Base class used for every default easing function.
  6375. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6376. */
  6377. export class EasingFunction implements IEasingFunction {
  6378. /**
  6379. * Interpolation follows the mathematical formula associated with the easing function.
  6380. */
  6381. static readonly EASINGMODE_EASEIN: number;
  6382. /**
  6383. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6384. */
  6385. static readonly EASINGMODE_EASEOUT: number;
  6386. /**
  6387. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6388. */
  6389. static readonly EASINGMODE_EASEINOUT: number;
  6390. private _easingMode;
  6391. /**
  6392. * Sets the easing mode of the current function.
  6393. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6394. */
  6395. setEasingMode(easingMode: number): void;
  6396. /**
  6397. * Gets the current easing mode.
  6398. * @returns the easing mode
  6399. */
  6400. getEasingMode(): number;
  6401. /**
  6402. * @hidden
  6403. */
  6404. easeInCore(gradient: number): number;
  6405. /**
  6406. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6407. * of the easing function.
  6408. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6409. * @returns the corresponding value on the curve defined by the easing function
  6410. */
  6411. ease(gradient: number): number;
  6412. }
  6413. /**
  6414. * Easing function with a circle shape (see link below).
  6415. * @see https://easings.net/#easeInCirc
  6416. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6417. */
  6418. export class CircleEase extends EasingFunction implements IEasingFunction {
  6419. /** @hidden */
  6420. easeInCore(gradient: number): number;
  6421. }
  6422. /**
  6423. * Easing function with a ease back shape (see link below).
  6424. * @see https://easings.net/#easeInBack
  6425. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6426. */
  6427. export class BackEase extends EasingFunction implements IEasingFunction {
  6428. /** Defines the amplitude of the function */
  6429. amplitude: number;
  6430. /**
  6431. * Instantiates a back ease easing
  6432. * @see https://easings.net/#easeInBack
  6433. * @param amplitude Defines the amplitude of the function
  6434. */
  6435. constructor(
  6436. /** Defines the amplitude of the function */
  6437. amplitude?: number);
  6438. /** @hidden */
  6439. easeInCore(gradient: number): number;
  6440. }
  6441. /**
  6442. * Easing function with a bouncing shape (see link below).
  6443. * @see https://easings.net/#easeInBounce
  6444. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6445. */
  6446. export class BounceEase extends EasingFunction implements IEasingFunction {
  6447. /** Defines the number of bounces */
  6448. bounces: number;
  6449. /** Defines the amplitude of the bounce */
  6450. bounciness: number;
  6451. /**
  6452. * Instantiates a bounce easing
  6453. * @see https://easings.net/#easeInBounce
  6454. * @param bounces Defines the number of bounces
  6455. * @param bounciness Defines the amplitude of the bounce
  6456. */
  6457. constructor(
  6458. /** Defines the number of bounces */
  6459. bounces?: number,
  6460. /** Defines the amplitude of the bounce */
  6461. bounciness?: number);
  6462. /** @hidden */
  6463. easeInCore(gradient: number): number;
  6464. }
  6465. /**
  6466. * Easing function with a power of 3 shape (see link below).
  6467. * @see https://easings.net/#easeInCubic
  6468. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6469. */
  6470. export class CubicEase extends EasingFunction implements IEasingFunction {
  6471. /** @hidden */
  6472. easeInCore(gradient: number): number;
  6473. }
  6474. /**
  6475. * Easing function with an elastic shape (see link below).
  6476. * @see https://easings.net/#easeInElastic
  6477. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6478. */
  6479. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6480. /** Defines the number of oscillations*/
  6481. oscillations: number;
  6482. /** Defines the amplitude of the oscillations*/
  6483. springiness: number;
  6484. /**
  6485. * Instantiates an elastic easing function
  6486. * @see https://easings.net/#easeInElastic
  6487. * @param oscillations Defines the number of oscillations
  6488. * @param springiness Defines the amplitude of the oscillations
  6489. */
  6490. constructor(
  6491. /** Defines the number of oscillations*/
  6492. oscillations?: number,
  6493. /** Defines the amplitude of the oscillations*/
  6494. springiness?: number);
  6495. /** @hidden */
  6496. easeInCore(gradient: number): number;
  6497. }
  6498. /**
  6499. * Easing function with an exponential shape (see link below).
  6500. * @see https://easings.net/#easeInExpo
  6501. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6502. */
  6503. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6504. /** Defines the exponent of the function */
  6505. exponent: number;
  6506. /**
  6507. * Instantiates an exponential easing function
  6508. * @see https://easings.net/#easeInExpo
  6509. * @param exponent Defines the exponent of the function
  6510. */
  6511. constructor(
  6512. /** Defines the exponent of the function */
  6513. exponent?: number);
  6514. /** @hidden */
  6515. easeInCore(gradient: number): number;
  6516. }
  6517. /**
  6518. * Easing function with a power shape (see link below).
  6519. * @see https://easings.net/#easeInQuad
  6520. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6521. */
  6522. export class PowerEase extends EasingFunction implements IEasingFunction {
  6523. /** Defines the power of the function */
  6524. power: number;
  6525. /**
  6526. * Instantiates an power base easing function
  6527. * @see https://easings.net/#easeInQuad
  6528. * @param power Defines the power of the function
  6529. */
  6530. constructor(
  6531. /** Defines the power of the function */
  6532. power?: number);
  6533. /** @hidden */
  6534. easeInCore(gradient: number): number;
  6535. }
  6536. /**
  6537. * Easing function with a power of 2 shape (see link below).
  6538. * @see https://easings.net/#easeInQuad
  6539. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6540. */
  6541. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6542. /** @hidden */
  6543. easeInCore(gradient: number): number;
  6544. }
  6545. /**
  6546. * Easing function with a power of 4 shape (see link below).
  6547. * @see https://easings.net/#easeInQuart
  6548. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6549. */
  6550. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6551. /** @hidden */
  6552. easeInCore(gradient: number): number;
  6553. }
  6554. /**
  6555. * Easing function with a power of 5 shape (see link below).
  6556. * @see https://easings.net/#easeInQuint
  6557. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6558. */
  6559. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6560. /** @hidden */
  6561. easeInCore(gradient: number): number;
  6562. }
  6563. /**
  6564. * Easing function with a sin shape (see link below).
  6565. * @see https://easings.net/#easeInSine
  6566. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6567. */
  6568. export class SineEase extends EasingFunction implements IEasingFunction {
  6569. /** @hidden */
  6570. easeInCore(gradient: number): number;
  6571. }
  6572. /**
  6573. * Easing function with a bezier shape (see link below).
  6574. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6575. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6576. */
  6577. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6578. /** Defines the x component of the start tangent in the bezier curve */
  6579. x1: number;
  6580. /** Defines the y component of the start tangent in the bezier curve */
  6581. y1: number;
  6582. /** Defines the x component of the end tangent in the bezier curve */
  6583. x2: number;
  6584. /** Defines the y component of the end tangent in the bezier curve */
  6585. y2: number;
  6586. /**
  6587. * Instantiates a bezier function
  6588. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6589. * @param x1 Defines the x component of the start tangent in the bezier curve
  6590. * @param y1 Defines the y component of the start tangent in the bezier curve
  6591. * @param x2 Defines the x component of the end tangent in the bezier curve
  6592. * @param y2 Defines the y component of the end tangent in the bezier curve
  6593. */
  6594. constructor(
  6595. /** Defines the x component of the start tangent in the bezier curve */
  6596. x1?: number,
  6597. /** Defines the y component of the start tangent in the bezier curve */
  6598. y1?: number,
  6599. /** Defines the x component of the end tangent in the bezier curve */
  6600. x2?: number,
  6601. /** Defines the y component of the end tangent in the bezier curve */
  6602. y2?: number);
  6603. /** @hidden */
  6604. easeInCore(gradient: number): number;
  6605. }
  6606. }
  6607. declare module BABYLON {
  6608. /**
  6609. * Defines an interface which represents an animation key frame
  6610. */
  6611. export interface IAnimationKey {
  6612. /**
  6613. * Frame of the key frame
  6614. */
  6615. frame: number;
  6616. /**
  6617. * Value at the specifies key frame
  6618. */
  6619. value: any;
  6620. /**
  6621. * The input tangent for the cubic hermite spline
  6622. */
  6623. inTangent?: any;
  6624. /**
  6625. * The output tangent for the cubic hermite spline
  6626. */
  6627. outTangent?: any;
  6628. /**
  6629. * The animation interpolation type
  6630. */
  6631. interpolation?: AnimationKeyInterpolation;
  6632. }
  6633. /**
  6634. * Enum for the animation key frame interpolation type
  6635. */
  6636. export enum AnimationKeyInterpolation {
  6637. /**
  6638. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6639. */
  6640. STEP = 1
  6641. }
  6642. }
  6643. declare module BABYLON {
  6644. /**
  6645. * Represents the range of an animation
  6646. */
  6647. export class AnimationRange {
  6648. /**The name of the animation range**/
  6649. name: string;
  6650. /**The starting frame of the animation */
  6651. from: number;
  6652. /**The ending frame of the animation*/
  6653. to: number;
  6654. /**
  6655. * Initializes the range of an animation
  6656. * @param name The name of the animation range
  6657. * @param from The starting frame of the animation
  6658. * @param to The ending frame of the animation
  6659. */
  6660. constructor(
  6661. /**The name of the animation range**/
  6662. name: string,
  6663. /**The starting frame of the animation */
  6664. from: number,
  6665. /**The ending frame of the animation*/
  6666. to: number);
  6667. /**
  6668. * Makes a copy of the animation range
  6669. * @returns A copy of the animation range
  6670. */
  6671. clone(): AnimationRange;
  6672. }
  6673. }
  6674. declare module BABYLON {
  6675. /**
  6676. * Composed of a frame, and an action function
  6677. */
  6678. export class AnimationEvent {
  6679. /** The frame for which the event is triggered **/
  6680. frame: number;
  6681. /** The event to perform when triggered **/
  6682. action: (currentFrame: number) => void;
  6683. /** Specifies if the event should be triggered only once**/
  6684. onlyOnce?: boolean | undefined;
  6685. /**
  6686. * Specifies if the animation event is done
  6687. */
  6688. isDone: boolean;
  6689. /**
  6690. * Initializes the animation event
  6691. * @param frame The frame for which the event is triggered
  6692. * @param action The event to perform when triggered
  6693. * @param onlyOnce Specifies if the event should be triggered only once
  6694. */
  6695. constructor(
  6696. /** The frame for which the event is triggered **/
  6697. frame: number,
  6698. /** The event to perform when triggered **/
  6699. action: (currentFrame: number) => void,
  6700. /** Specifies if the event should be triggered only once**/
  6701. onlyOnce?: boolean | undefined);
  6702. /** @hidden */ clone(): AnimationEvent;
  6703. }
  6704. }
  6705. declare module BABYLON {
  6706. /**
  6707. * Interface used to define a behavior
  6708. */
  6709. export interface Behavior<T> {
  6710. /** gets or sets behavior's name */
  6711. name: string;
  6712. /**
  6713. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6714. */
  6715. init(): void;
  6716. /**
  6717. * Called when the behavior is attached to a target
  6718. * @param target defines the target where the behavior is attached to
  6719. */
  6720. attach(target: T): void;
  6721. /**
  6722. * Called when the behavior is detached from its target
  6723. */
  6724. detach(): void;
  6725. }
  6726. /**
  6727. * Interface implemented by classes supporting behaviors
  6728. */
  6729. export interface IBehaviorAware<T> {
  6730. /**
  6731. * Attach a behavior
  6732. * @param behavior defines the behavior to attach
  6733. * @returns the current host
  6734. */
  6735. addBehavior(behavior: Behavior<T>): T;
  6736. /**
  6737. * Remove a behavior from the current object
  6738. * @param behavior defines the behavior to detach
  6739. * @returns the current host
  6740. */
  6741. removeBehavior(behavior: Behavior<T>): T;
  6742. /**
  6743. * Gets a behavior using its name to search
  6744. * @param name defines the name to search
  6745. * @returns the behavior or null if not found
  6746. */
  6747. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6748. }
  6749. }
  6750. declare module BABYLON {
  6751. /**
  6752. * @hidden
  6753. */
  6754. export class IntersectionInfo {
  6755. bu: Nullable<number>;
  6756. bv: Nullable<number>;
  6757. distance: number;
  6758. faceId: number;
  6759. subMeshId: number;
  6760. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6761. }
  6762. }
  6763. declare module BABYLON {
  6764. /**
  6765. * Class used to store bounding sphere information
  6766. */
  6767. export class BoundingSphere {
  6768. /**
  6769. * Gets the center of the bounding sphere in local space
  6770. */
  6771. readonly center: Vector3;
  6772. /**
  6773. * Radius of the bounding sphere in local space
  6774. */
  6775. radius: number;
  6776. /**
  6777. * Gets the center of the bounding sphere in world space
  6778. */
  6779. readonly centerWorld: Vector3;
  6780. /**
  6781. * Radius of the bounding sphere in world space
  6782. */
  6783. radiusWorld: number;
  6784. /**
  6785. * Gets the minimum vector in local space
  6786. */
  6787. readonly minimum: Vector3;
  6788. /**
  6789. * Gets the maximum vector in local space
  6790. */
  6791. readonly maximum: Vector3;
  6792. private _worldMatrix;
  6793. private static readonly TmpVector3;
  6794. /**
  6795. * Creates a new bounding sphere
  6796. * @param min defines the minimum vector (in local space)
  6797. * @param max defines the maximum vector (in local space)
  6798. * @param worldMatrix defines the new world matrix
  6799. */
  6800. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6801. /**
  6802. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6803. * @param min defines the new minimum vector (in local space)
  6804. * @param max defines the new maximum vector (in local space)
  6805. * @param worldMatrix defines the new world matrix
  6806. */
  6807. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6808. /**
  6809. * Scale the current bounding sphere by applying a scale factor
  6810. * @param factor defines the scale factor to apply
  6811. * @returns the current bounding box
  6812. */
  6813. scale(factor: number): BoundingSphere;
  6814. /**
  6815. * Gets the world matrix of the bounding box
  6816. * @returns a matrix
  6817. */
  6818. getWorldMatrix(): DeepImmutable<Matrix>;
  6819. /** @hidden */ update(worldMatrix: DeepImmutable<Matrix>): void;
  6820. /**
  6821. * Tests if the bounding sphere is intersecting the frustum planes
  6822. * @param frustumPlanes defines the frustum planes to test
  6823. * @returns true if there is an intersection
  6824. */
  6825. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6826. /**
  6827. * Tests if the bounding sphere center is in between the frustum planes.
  6828. * Used for optimistic fast inclusion.
  6829. * @param frustumPlanes defines the frustum planes to test
  6830. * @returns true if the sphere center is in between the frustum planes
  6831. */
  6832. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6833. /**
  6834. * Tests if a point is inside the bounding sphere
  6835. * @param point defines the point to test
  6836. * @returns true if the point is inside the bounding sphere
  6837. */
  6838. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6839. /**
  6840. * Checks if two sphere intersct
  6841. * @param sphere0 sphere 0
  6842. * @param sphere1 sphere 1
  6843. * @returns true if the speres intersect
  6844. */
  6845. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6846. }
  6847. }
  6848. declare module BABYLON {
  6849. /**
  6850. * Class used to store bounding box information
  6851. */
  6852. export class BoundingBox implements ICullable {
  6853. /**
  6854. * Gets the 8 vectors representing the bounding box in local space
  6855. */
  6856. readonly vectors: Vector3[];
  6857. /**
  6858. * Gets the center of the bounding box in local space
  6859. */
  6860. readonly center: Vector3;
  6861. /**
  6862. * Gets the center of the bounding box in world space
  6863. */
  6864. readonly centerWorld: Vector3;
  6865. /**
  6866. * Gets the extend size in local space
  6867. */
  6868. readonly extendSize: Vector3;
  6869. /**
  6870. * Gets the extend size in world space
  6871. */
  6872. readonly extendSizeWorld: Vector3;
  6873. /**
  6874. * Gets the OBB (object bounding box) directions
  6875. */
  6876. readonly directions: Vector3[];
  6877. /**
  6878. * Gets the 8 vectors representing the bounding box in world space
  6879. */
  6880. readonly vectorsWorld: Vector3[];
  6881. /**
  6882. * Gets the minimum vector in world space
  6883. */
  6884. readonly minimumWorld: Vector3;
  6885. /**
  6886. * Gets the maximum vector in world space
  6887. */
  6888. readonly maximumWorld: Vector3;
  6889. /**
  6890. * Gets the minimum vector in local space
  6891. */
  6892. readonly minimum: Vector3;
  6893. /**
  6894. * Gets the maximum vector in local space
  6895. */
  6896. readonly maximum: Vector3;
  6897. private _worldMatrix;
  6898. private static readonly TmpVector3;
  6899. /**
  6900. * @hidden
  6901. */ tag: number;
  6902. /**
  6903. * Creates a new bounding box
  6904. * @param min defines the minimum vector (in local space)
  6905. * @param max defines the maximum vector (in local space)
  6906. * @param worldMatrix defines the new world matrix
  6907. */
  6908. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6909. /**
  6910. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6911. * @param min defines the new minimum vector (in local space)
  6912. * @param max defines the new maximum vector (in local space)
  6913. * @param worldMatrix defines the new world matrix
  6914. */
  6915. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6916. /**
  6917. * Scale the current bounding box by applying a scale factor
  6918. * @param factor defines the scale factor to apply
  6919. * @returns the current bounding box
  6920. */
  6921. scale(factor: number): BoundingBox;
  6922. /**
  6923. * Gets the world matrix of the bounding box
  6924. * @returns a matrix
  6925. */
  6926. getWorldMatrix(): DeepImmutable<Matrix>;
  6927. /** @hidden */ update(world: DeepImmutable<Matrix>): void;
  6928. /**
  6929. * Tests if the bounding box is intersecting the frustum planes
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @returns true if there is an intersection
  6932. */
  6933. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if the bounding box is entirely inside the frustum planes
  6936. * @param frustumPlanes defines the frustum planes to test
  6937. * @returns true if there is an inclusion
  6938. */
  6939. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6940. /**
  6941. * Tests if a point is inside the bounding box
  6942. * @param point defines the point to test
  6943. * @returns true if the point is inside the bounding box
  6944. */
  6945. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6946. /**
  6947. * Tests if the bounding box intersects with a bounding sphere
  6948. * @param sphere defines the sphere to test
  6949. * @returns true if there is an intersection
  6950. */
  6951. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6952. /**
  6953. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6954. * @param min defines the min vector to use
  6955. * @param max defines the max vector to use
  6956. * @returns true if there is an intersection
  6957. */
  6958. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6959. /**
  6960. * Tests if two bounding boxes are intersections
  6961. * @param box0 defines the first box to test
  6962. * @param box1 defines the second box to test
  6963. * @returns true if there is an intersection
  6964. */
  6965. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6966. /**
  6967. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6968. * @param minPoint defines the minimum vector of the bounding box
  6969. * @param maxPoint defines the maximum vector of the bounding box
  6970. * @param sphereCenter defines the sphere center
  6971. * @param sphereRadius defines the sphere radius
  6972. * @returns true if there is an intersection
  6973. */
  6974. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6975. /**
  6976. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6977. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6978. * @param frustumPlanes defines the frustum planes to test
  6979. * @return true if there is an inclusion
  6980. */
  6981. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6982. /**
  6983. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6984. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6985. * @param frustumPlanes defines the frustum planes to test
  6986. * @return true if there is an intersection
  6987. */
  6988. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6989. }
  6990. }
  6991. declare module BABYLON {
  6992. /** @hidden */
  6993. export class Collider {
  6994. /** Define if a collision was found */
  6995. collisionFound: boolean;
  6996. /**
  6997. * Define last intersection point in local space
  6998. */
  6999. intersectionPoint: Vector3;
  7000. /**
  7001. * Define last collided mesh
  7002. */
  7003. collidedMesh: Nullable<AbstractMesh>;
  7004. private _collisionPoint;
  7005. private _planeIntersectionPoint;
  7006. private _tempVector;
  7007. private _tempVector2;
  7008. private _tempVector3;
  7009. private _tempVector4;
  7010. private _edge;
  7011. private _baseToVertex;
  7012. private _destinationPoint;
  7013. private _slidePlaneNormal;
  7014. private _displacementVector;
  7015. /** @hidden */ radius: Vector3;
  7016. /** @hidden */ retry: number;
  7017. private _velocity;
  7018. private _basePoint;
  7019. private _epsilon;
  7020. /** @hidden */ velocityWorldLength: number;
  7021. /** @hidden */ basePointWorld: Vector3;
  7022. private _velocityWorld;
  7023. private _normalizedVelocity;
  7024. /** @hidden */ initialVelocity: Vector3;
  7025. /** @hidden */ initialPosition: Vector3;
  7026. private _nearestDistance;
  7027. private _collisionMask;
  7028. collisionMask: number;
  7029. /**
  7030. * Gets the plane normal used to compute the sliding response (in local space)
  7031. */
  7032. readonly slidePlaneNormal: Vector3;
  7033. /** @hidden */ initialize(source: Vector3, dir: Vector3, e: number): void;
  7034. /** @hidden */ checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7035. /** @hidden */ canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7036. /** @hidden */ testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7037. /** @hidden */ collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7038. /** @hidden */ getResponse(pos: Vector3, vel: Vector3): void;
  7039. }
  7040. }
  7041. declare module BABYLON {
  7042. /**
  7043. * Interface for cullable objects
  7044. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7045. */
  7046. export interface ICullable {
  7047. /**
  7048. * Checks if the object or part of the object is in the frustum
  7049. * @param frustumPlanes Camera near/planes
  7050. * @returns true if the object is in frustum otherwise false
  7051. */
  7052. isInFrustum(frustumPlanes: Plane[]): boolean;
  7053. /**
  7054. * Checks if a cullable object (mesh...) is in the camera frustum
  7055. * Unlike isInFrustum this cheks the full bounding box
  7056. * @param frustumPlanes Camera near/planes
  7057. * @returns true if the object is in frustum otherwise false
  7058. */
  7059. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7060. }
  7061. /**
  7062. * Info for a bounding data of a mesh
  7063. */
  7064. export class BoundingInfo implements ICullable {
  7065. /**
  7066. * Bounding box for the mesh
  7067. */
  7068. readonly boundingBox: BoundingBox;
  7069. /**
  7070. * Bounding sphere for the mesh
  7071. */
  7072. readonly boundingSphere: BoundingSphere;
  7073. private _isLocked;
  7074. private static readonly TmpVector3;
  7075. /**
  7076. * Constructs bounding info
  7077. * @param minimum min vector of the bounding box/sphere
  7078. * @param maximum max vector of the bounding box/sphere
  7079. * @param worldMatrix defines the new world matrix
  7080. */
  7081. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7082. /**
  7083. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7084. * @param min defines the new minimum vector (in local space)
  7085. * @param max defines the new maximum vector (in local space)
  7086. * @param worldMatrix defines the new world matrix
  7087. */
  7088. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7089. /**
  7090. * min vector of the bounding box/sphere
  7091. */
  7092. readonly minimum: Vector3;
  7093. /**
  7094. * max vector of the bounding box/sphere
  7095. */
  7096. readonly maximum: Vector3;
  7097. /**
  7098. * If the info is locked and won't be updated to avoid perf overhead
  7099. */
  7100. isLocked: boolean;
  7101. /**
  7102. * Updates the bounding sphere and box
  7103. * @param world world matrix to be used to update
  7104. */
  7105. update(world: DeepImmutable<Matrix>): void;
  7106. /**
  7107. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7108. * @param center New center of the bounding info
  7109. * @param extend New extend of the bounding info
  7110. * @returns the current bounding info
  7111. */
  7112. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7113. /**
  7114. * Scale the current bounding info by applying a scale factor
  7115. * @param factor defines the scale factor to apply
  7116. * @returns the current bounding info
  7117. */
  7118. scale(factor: number): BoundingInfo;
  7119. /**
  7120. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7121. * @param frustumPlanes defines the frustum to test
  7122. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7123. * @returns true if the bounding info is in the frustum planes
  7124. */
  7125. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7126. /**
  7127. * Gets the world distance between the min and max points of the bounding box
  7128. */
  7129. readonly diagonalLength: number;
  7130. /**
  7131. * Checks if a cullable object (mesh...) is in the camera frustum
  7132. * Unlike isInFrustum this cheks the full bounding box
  7133. * @param frustumPlanes Camera near/planes
  7134. * @returns true if the object is in frustum otherwise false
  7135. */
  7136. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7137. /** @hidden */ checkCollision(collider: Collider): boolean;
  7138. /**
  7139. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7140. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7141. * @param point the point to check intersection with
  7142. * @returns if the point intersects
  7143. */
  7144. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7145. /**
  7146. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7147. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7148. * @param boundingInfo the bounding info to check intersection with
  7149. * @param precise if the intersection should be done using OBB
  7150. * @returns if the bounding info intersects
  7151. */
  7152. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7153. }
  7154. }
  7155. declare module BABYLON {
  7156. /**
  7157. * Defines an array and its length.
  7158. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7159. */
  7160. export interface ISmartArrayLike<T> {
  7161. /**
  7162. * The data of the array.
  7163. */
  7164. data: Array<T>;
  7165. /**
  7166. * The active length of the array.
  7167. */
  7168. length: number;
  7169. }
  7170. /**
  7171. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7172. */
  7173. export class SmartArray<T> implements ISmartArrayLike<T> {
  7174. /**
  7175. * The full set of data from the array.
  7176. */
  7177. data: Array<T>;
  7178. /**
  7179. * The active length of the array.
  7180. */
  7181. length: number;
  7182. protected _id: number;
  7183. /**
  7184. * Instantiates a Smart Array.
  7185. * @param capacity defines the default capacity of the array.
  7186. */
  7187. constructor(capacity: number);
  7188. /**
  7189. * Pushes a value at the end of the active data.
  7190. * @param value defines the object to push in the array.
  7191. */
  7192. push(value: T): void;
  7193. /**
  7194. * Iterates over the active data and apply the lambda to them.
  7195. * @param func defines the action to apply on each value.
  7196. */
  7197. forEach(func: (content: T) => void): void;
  7198. /**
  7199. * Sorts the full sets of data.
  7200. * @param compareFn defines the comparison function to apply.
  7201. */
  7202. sort(compareFn: (a: T, b: T) => number): void;
  7203. /**
  7204. * Resets the active data to an empty array.
  7205. */
  7206. reset(): void;
  7207. /**
  7208. * Releases all the data from the array as well as the array.
  7209. */
  7210. dispose(): void;
  7211. /**
  7212. * Concats the active data with a given array.
  7213. * @param array defines the data to concatenate with.
  7214. */
  7215. concat(array: any): void;
  7216. /**
  7217. * Returns the position of a value in the active data.
  7218. * @param value defines the value to find the index for
  7219. * @returns the index if found in the active data otherwise -1
  7220. */
  7221. indexOf(value: T): number;
  7222. /**
  7223. * Returns whether an element is part of the active data.
  7224. * @param value defines the value to look for
  7225. * @returns true if found in the active data otherwise false
  7226. */
  7227. contains(value: T): boolean;
  7228. private static _GlobalId;
  7229. }
  7230. /**
  7231. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7232. * The data in this array can only be present once
  7233. */
  7234. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7235. private _duplicateId;
  7236. /**
  7237. * Pushes a value at the end of the active data.
  7238. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7239. * @param value defines the object to push in the array.
  7240. */
  7241. push(value: T): void;
  7242. /**
  7243. * Pushes a value at the end of the active data.
  7244. * If the data is already present, it won t be added again
  7245. * @param value defines the object to push in the array.
  7246. * @returns true if added false if it was already present
  7247. */
  7248. pushNoDuplicate(value: T): boolean;
  7249. /**
  7250. * Resets the active data to an empty array.
  7251. */
  7252. reset(): void;
  7253. /**
  7254. * Concats the active data with a given array.
  7255. * This ensures no dupplicate will be present in the result.
  7256. * @param array defines the data to concatenate with.
  7257. */
  7258. concatWithNoDuplicate(array: any): void;
  7259. }
  7260. }
  7261. declare module BABYLON {
  7262. /**
  7263. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7264. * separate meshes. This can be use to improve performances.
  7265. * @see http://doc.babylonjs.com/how_to/multi_materials
  7266. */
  7267. export class MultiMaterial extends Material {
  7268. private _subMaterials;
  7269. /**
  7270. * Gets or Sets the list of Materials used within the multi material.
  7271. * They need to be ordered according to the submeshes order in the associated mesh
  7272. */
  7273. subMaterials: Nullable<Material>[];
  7274. /**
  7275. * Function used to align with Node.getChildren()
  7276. * @returns the list of Materials used within the multi material
  7277. */
  7278. getChildren(): Nullable<Material>[];
  7279. /**
  7280. * Instantiates a new Multi Material
  7281. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7282. * separate meshes. This can be use to improve performances.
  7283. * @see http://doc.babylonjs.com/how_to/multi_materials
  7284. * @param name Define the name in the scene
  7285. * @param scene Define the scene the material belongs to
  7286. */
  7287. constructor(name: string, scene: Scene);
  7288. private _hookArray;
  7289. /**
  7290. * Get one of the submaterial by its index in the submaterials array
  7291. * @param index The index to look the sub material at
  7292. * @returns The Material if the index has been defined
  7293. */
  7294. getSubMaterial(index: number): Nullable<Material>;
  7295. /**
  7296. * Get the list of active textures for the whole sub materials list.
  7297. * @returns All the textures that will be used during the rendering
  7298. */
  7299. getActiveTextures(): BaseTexture[];
  7300. /**
  7301. * Gets the current class name of the material e.g. "MultiMaterial"
  7302. * Mainly use in serialization.
  7303. * @returns the class name
  7304. */
  7305. getClassName(): string;
  7306. /**
  7307. * Checks if the material is ready to render the requested sub mesh
  7308. * @param mesh Define the mesh the submesh belongs to
  7309. * @param subMesh Define the sub mesh to look readyness for
  7310. * @param useInstances Define whether or not the material is used with instances
  7311. * @returns true if ready, otherwise false
  7312. */
  7313. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7314. /**
  7315. * Clones the current material and its related sub materials
  7316. * @param name Define the name of the newly cloned material
  7317. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7318. * @returns the cloned material
  7319. */
  7320. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7321. /**
  7322. * Serializes the materials into a JSON representation.
  7323. * @returns the JSON representation
  7324. */
  7325. serialize(): any;
  7326. /**
  7327. * Dispose the material and release its associated resources
  7328. * @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)
  7329. * @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)
  7330. * @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)
  7331. */
  7332. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7333. /**
  7334. * Creates a MultiMaterial from parsed MultiMaterial data.
  7335. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7336. * @param scene defines the hosting scene
  7337. * @returns a new MultiMaterial
  7338. */
  7339. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7340. }
  7341. }
  7342. declare module BABYLON {
  7343. /**
  7344. * Class used to represent data loading progression
  7345. */
  7346. export class SceneLoaderFlags {
  7347. private static _ForceFullSceneLoadingForIncremental;
  7348. private static _ShowLoadingScreen;
  7349. private static _CleanBoneMatrixWeights;
  7350. private static _loggingLevel;
  7351. /**
  7352. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7353. */
  7354. static ForceFullSceneLoadingForIncremental: boolean;
  7355. /**
  7356. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7357. */
  7358. static ShowLoadingScreen: boolean;
  7359. /**
  7360. * Defines the current logging level (while loading the scene)
  7361. * @ignorenaming
  7362. */
  7363. static loggingLevel: number;
  7364. /**
  7365. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7366. */
  7367. static CleanBoneMatrixWeights: boolean;
  7368. }
  7369. }
  7370. declare module BABYLON {
  7371. /**
  7372. * 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.
  7373. * @see https://doc.babylonjs.com/how_to/transformnode
  7374. */
  7375. export class TransformNode extends Node {
  7376. /**
  7377. * Object will not rotate to face the camera
  7378. */
  7379. static BILLBOARDMODE_NONE: number;
  7380. /**
  7381. * Object will rotate to face the camera but only on the x axis
  7382. */
  7383. static BILLBOARDMODE_X: number;
  7384. /**
  7385. * Object will rotate to face the camera but only on the y axis
  7386. */
  7387. static BILLBOARDMODE_Y: number;
  7388. /**
  7389. * Object will rotate to face the camera but only on the z axis
  7390. */
  7391. static BILLBOARDMODE_Z: number;
  7392. /**
  7393. * Object will rotate to face the camera
  7394. */
  7395. static BILLBOARDMODE_ALL: number;
  7396. private _forward;
  7397. private _forwardInverted;
  7398. private _up;
  7399. private _right;
  7400. private _rightInverted;
  7401. private _position;
  7402. private _rotation;
  7403. private _rotationQuaternion;
  7404. protected _scaling: Vector3;
  7405. protected _isDirty: boolean;
  7406. private _transformToBoneReferal;
  7407. private _billboardMode;
  7408. /**
  7409. * Gets or sets the billboard mode. Default is 0.
  7410. *
  7411. * | Value | Type | Description |
  7412. * | --- | --- | --- |
  7413. * | 0 | BILLBOARDMODE_NONE | |
  7414. * | 1 | BILLBOARDMODE_X | |
  7415. * | 2 | BILLBOARDMODE_Y | |
  7416. * | 4 | BILLBOARDMODE_Z | |
  7417. * | 7 | BILLBOARDMODE_ALL | |
  7418. *
  7419. */
  7420. billboardMode: number;
  7421. private _preserveParentRotationForBillboard;
  7422. /**
  7423. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7424. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7425. */
  7426. preserveParentRotationForBillboard: boolean;
  7427. /**
  7428. * 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
  7429. */
  7430. scalingDeterminant: number;
  7431. private _infiniteDistance;
  7432. /**
  7433. * Gets or sets the distance of the object to max, often used by skybox
  7434. */
  7435. infiniteDistance: boolean;
  7436. /**
  7437. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7438. * By default the system will update normals to compensate
  7439. */
  7440. ignoreNonUniformScaling: boolean;
  7441. /**
  7442. * 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
  7443. */
  7444. reIntegrateRotationIntoRotationQuaternion: boolean;
  7445. /** @hidden */ poseMatrix: Matrix;
  7446. /** @hidden */ localMatrix: Matrix;
  7447. private _absolutePosition;
  7448. private _pivotMatrix;
  7449. private _pivotMatrixInverse;
  7450. protected _postMultiplyPivotMatrix: boolean;
  7451. protected _isWorldMatrixFrozen: boolean;
  7452. /** @hidden */ indexInSceneTransformNodesArray: number;
  7453. private _connectBillboardProcessors;
  7454. /**
  7455. * An event triggered after the world matrix is updated
  7456. */
  7457. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7458. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7459. /**
  7460. * Gets a string identifying the name of the class
  7461. * @returns "TransformNode" string
  7462. */
  7463. getClassName(): string;
  7464. /**
  7465. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7466. */
  7467. position: Vector3;
  7468. /**
  7469. * 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)).
  7470. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7471. */
  7472. rotation: Vector3;
  7473. /**
  7474. * 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)).
  7475. */
  7476. scaling: Vector3;
  7477. /**
  7478. * 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).
  7479. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7480. */
  7481. rotationQuaternion: Nullable<Quaternion>;
  7482. /**
  7483. * The forward direction of that transform in world space.
  7484. */
  7485. readonly forward: Vector3;
  7486. /**
  7487. * The up direction of that transform in world space.
  7488. */
  7489. readonly up: Vector3;
  7490. /**
  7491. * The right direction of that transform in world space.
  7492. */
  7493. readonly right: Vector3;
  7494. /**
  7495. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7496. * @param matrix the matrix to copy the pose from
  7497. * @returns this TransformNode.
  7498. */
  7499. updatePoseMatrix(matrix: Matrix): TransformNode;
  7500. /**
  7501. * Returns the mesh Pose matrix.
  7502. * @returns the pose matrix
  7503. */
  7504. getPoseMatrix(): Matrix;
  7505. /** @hidden */ isSynchronized(): boolean;
  7506. /** @hidden */ initCache(): void;
  7507. /**
  7508. * Flag the transform node as dirty (Forcing it to update everything)
  7509. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7510. * @returns this transform node
  7511. */
  7512. markAsDirty(property: string): TransformNode;
  7513. /**
  7514. * Returns the current mesh absolute position.
  7515. * Returns a Vector3.
  7516. */
  7517. readonly absolutePosition: Vector3;
  7518. /**
  7519. * Sets a new matrix to apply before all other transformation
  7520. * @param matrix defines the transform matrix
  7521. * @returns the current TransformNode
  7522. */
  7523. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7524. /**
  7525. * Sets a new pivot matrix to the current node
  7526. * @param matrix defines the new pivot matrix to use
  7527. * @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
  7528. * @returns the current TransformNode
  7529. */
  7530. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7531. /**
  7532. * Returns the mesh pivot matrix.
  7533. * Default : Identity.
  7534. * @returns the matrix
  7535. */
  7536. getPivotMatrix(): Matrix;
  7537. /**
  7538. * Prevents the World matrix to be computed any longer.
  7539. * @returns the TransformNode.
  7540. */
  7541. freezeWorldMatrix(): TransformNode;
  7542. /**
  7543. * Allows back the World matrix computation.
  7544. * @returns the TransformNode.
  7545. */
  7546. unfreezeWorldMatrix(): this;
  7547. /**
  7548. * True if the World matrix has been frozen.
  7549. */
  7550. readonly isWorldMatrixFrozen: boolean;
  7551. /**
  7552. * Retuns the mesh absolute position in the World.
  7553. * @returns a Vector3.
  7554. */
  7555. getAbsolutePosition(): Vector3;
  7556. /**
  7557. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7558. * @param absolutePosition the absolute position to set
  7559. * @returns the TransformNode.
  7560. */
  7561. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7562. /**
  7563. * Sets the mesh position in its local space.
  7564. * @param vector3 the position to set in localspace
  7565. * @returns the TransformNode.
  7566. */
  7567. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7568. /**
  7569. * Returns the mesh position in the local space from the current World matrix values.
  7570. * @returns a new Vector3.
  7571. */
  7572. getPositionExpressedInLocalSpace(): Vector3;
  7573. /**
  7574. * Translates the mesh along the passed Vector3 in its local space.
  7575. * @param vector3 the distance to translate in localspace
  7576. * @returns the TransformNode.
  7577. */
  7578. locallyTranslate(vector3: Vector3): TransformNode;
  7579. private static _lookAtVectorCache;
  7580. /**
  7581. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7582. * @param targetPoint the position (must be in same space as current mesh) to look at
  7583. * @param yawCor optional yaw (y-axis) correction in radians
  7584. * @param pitchCor optional pitch (x-axis) correction in radians
  7585. * @param rollCor optional roll (z-axis) correction in radians
  7586. * @param space the choosen space of the target
  7587. * @returns the TransformNode.
  7588. */
  7589. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7590. /**
  7591. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7592. * This Vector3 is expressed in the World space.
  7593. * @param localAxis axis to rotate
  7594. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7595. */
  7596. getDirection(localAxis: Vector3): Vector3;
  7597. /**
  7598. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7599. * localAxis is expressed in the mesh local space.
  7600. * result is computed in the Wordl space from the mesh World matrix.
  7601. * @param localAxis axis to rotate
  7602. * @param result the resulting transformnode
  7603. * @returns this TransformNode.
  7604. */
  7605. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7606. /**
  7607. * Sets this transform node rotation to the given local axis.
  7608. * @param localAxis the axis in local space
  7609. * @param yawCor optional yaw (y-axis) correction in radians
  7610. * @param pitchCor optional pitch (x-axis) correction in radians
  7611. * @param rollCor optional roll (z-axis) correction in radians
  7612. * @returns this TransformNode
  7613. */
  7614. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7615. /**
  7616. * Sets a new pivot point to the current node
  7617. * @param point defines the new pivot point to use
  7618. * @param space defines if the point is in world or local space (local by default)
  7619. * @returns the current TransformNode
  7620. */
  7621. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7622. /**
  7623. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7624. * @returns the pivot point
  7625. */
  7626. getPivotPoint(): Vector3;
  7627. /**
  7628. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7629. * @param result the vector3 to store the result
  7630. * @returns this TransformNode.
  7631. */
  7632. getPivotPointToRef(result: Vector3): TransformNode;
  7633. /**
  7634. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7635. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7636. */
  7637. getAbsolutePivotPoint(): Vector3;
  7638. /**
  7639. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7640. * @param result vector3 to store the result
  7641. * @returns this TransformNode.
  7642. */
  7643. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7644. /**
  7645. * Defines the passed node as the parent of the current node.
  7646. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7647. * @see https://doc.babylonjs.com/how_to/parenting
  7648. * @param node the node ot set as the parent
  7649. * @returns this TransformNode.
  7650. */
  7651. setParent(node: Nullable<Node>): TransformNode;
  7652. private _nonUniformScaling;
  7653. /**
  7654. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7655. */
  7656. readonly nonUniformScaling: boolean;
  7657. /** @hidden */ updateNonUniformScalingState(value: boolean): boolean;
  7658. /**
  7659. * Attach the current TransformNode to another TransformNode associated with a bone
  7660. * @param bone Bone affecting the TransformNode
  7661. * @param affectedTransformNode TransformNode associated with the bone
  7662. * @returns this object
  7663. */
  7664. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7665. /**
  7666. * Detach the transform node if its associated with a bone
  7667. * @returns this object
  7668. */
  7669. detachFromBone(): TransformNode;
  7670. private static _rotationAxisCache;
  7671. /**
  7672. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7673. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7674. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7675. * The passed axis is also normalized.
  7676. * @param axis the axis to rotate around
  7677. * @param amount the amount to rotate in radians
  7678. * @param space Space to rotate in (Default: local)
  7679. * @returns the TransformNode.
  7680. */
  7681. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7682. /**
  7683. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7684. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7685. * The passed axis is also normalized. .
  7686. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7687. * @param point the point to rotate around
  7688. * @param axis the axis to rotate around
  7689. * @param amount the amount to rotate in radians
  7690. * @returns the TransformNode
  7691. */
  7692. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7693. /**
  7694. * Translates the mesh along the axis vector for the passed distance in the given space.
  7695. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7696. * @param axis the axis to translate in
  7697. * @param distance the distance to translate
  7698. * @param space Space to rotate in (Default: local)
  7699. * @returns the TransformNode.
  7700. */
  7701. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7702. /**
  7703. * Adds a rotation step to the mesh current rotation.
  7704. * x, y, z are Euler angles expressed in radians.
  7705. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7706. * This means this rotation is made in the mesh local space only.
  7707. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7708. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7709. * ```javascript
  7710. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7711. * ```
  7712. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7713. * 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.
  7714. * @param x Rotation to add
  7715. * @param y Rotation to add
  7716. * @param z Rotation to add
  7717. * @returns the TransformNode.
  7718. */
  7719. addRotation(x: number, y: number, z: number): TransformNode;
  7720. /**
  7721. * @hidden
  7722. */
  7723. protected _getEffectiveParent(): Nullable<Node>;
  7724. private _activeCompositionProcessor;
  7725. private _defaultCompositionProcessor;
  7726. private _pivotCompositionProcessor;
  7727. private _translationProcessor;
  7728. private _defaultTranslationProcessor;
  7729. private _infiniteDistanceTranslationProcessor;
  7730. private _activeParentProcessor;
  7731. private _activeBillboardPostProcessor;
  7732. private _defaultParentProcessor;
  7733. private _billboardParentProcessor;
  7734. private _billboardPostProcessor;
  7735. /**
  7736. * Computes the world matrix of the node
  7737. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7738. * @returns the world matrix
  7739. */
  7740. computeWorldMatrix(force?: boolean): Matrix;
  7741. protected _afterComputeWorldMatrix(): void;
  7742. /**
  7743. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7744. * @param func callback function to add
  7745. *
  7746. * @returns the TransformNode.
  7747. */
  7748. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7749. /**
  7750. * Removes a registered callback function.
  7751. * @param func callback function to remove
  7752. * @returns the TransformNode.
  7753. */
  7754. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7755. /**
  7756. * Gets the position of the current mesh in camera space
  7757. * @param camera defines the camera to use
  7758. * @returns a position
  7759. */
  7760. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7761. /**
  7762. * Returns the distance from the mesh to the active camera
  7763. * @param camera defines the camera to use
  7764. * @returns the distance
  7765. */
  7766. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7767. /**
  7768. * Clone the current transform node
  7769. * @param name Name of the new clone
  7770. * @param newParent New parent for the clone
  7771. * @param doNotCloneChildren Do not clone children hierarchy
  7772. * @returns the new transform node
  7773. */
  7774. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7775. /**
  7776. * Serializes the objects information.
  7777. * @param currentSerializationObject defines the object to serialize in
  7778. * @returns the serialized object
  7779. */
  7780. serialize(currentSerializationObject?: any): any;
  7781. /**
  7782. * Returns a new TransformNode object parsed from the source provided.
  7783. * @param parsedTransformNode is the source.
  7784. * @param scene the scne the object belongs to
  7785. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7786. * @returns a new TransformNode object parsed from the source provided.
  7787. */
  7788. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7789. /**
  7790. * Get all child-transformNodes of this node
  7791. * @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
  7792. * @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
  7793. * @returns an array of TransformNode
  7794. */
  7795. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7796. /**
  7797. * Releases resources associated with this transform node.
  7798. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7799. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7800. */
  7801. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7802. }
  7803. }
  7804. declare module BABYLON {
  7805. /**
  7806. * Class used to override all child animations of a given target
  7807. */
  7808. export class AnimationPropertiesOverride {
  7809. /**
  7810. * Gets or sets a value indicating if animation blending must be used
  7811. */
  7812. enableBlending: boolean;
  7813. /**
  7814. * Gets or sets the blending speed to use when enableBlending is true
  7815. */
  7816. blendingSpeed: number;
  7817. /**
  7818. * Gets or sets the default loop mode to use
  7819. */
  7820. loopMode: number;
  7821. }
  7822. }
  7823. declare module BABYLON {
  7824. /**
  7825. * Class used to store bone information
  7826. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7827. */
  7828. export class Bone extends Node {
  7829. /**
  7830. * defines the bone name
  7831. */
  7832. name: string;
  7833. private static _tmpVecs;
  7834. private static _tmpQuat;
  7835. private static _tmpMats;
  7836. /**
  7837. * Gets the list of child bones
  7838. */
  7839. children: Bone[];
  7840. /** Gets the animations associated with this bone */
  7841. animations: Animation[];
  7842. /**
  7843. * Gets or sets bone length
  7844. */
  7845. length: number;
  7846. /**
  7847. * @hidden Internal only
  7848. * Set this value to map this bone to a different index in the transform matrices
  7849. * Set this value to -1 to exclude the bone from the transform matrices
  7850. */ index: Nullable<number>;
  7851. private _skeleton;
  7852. private _localMatrix;
  7853. private _restPose;
  7854. private _baseMatrix;
  7855. private _absoluteTransform;
  7856. private _invertedAbsoluteTransform;
  7857. private _parent;
  7858. private _scalingDeterminant;
  7859. private _worldTransform;
  7860. private _localScaling;
  7861. private _localRotation;
  7862. private _localPosition;
  7863. private _needToDecompose;
  7864. private _needToCompose;
  7865. /** @hidden */ linkedTransformNode: Nullable<TransformNode>;
  7866. /** @hidden */
  7867. /** @hidden */ matrix: Matrix;
  7868. /**
  7869. * Create a new bone
  7870. * @param name defines the bone name
  7871. * @param skeleton defines the parent skeleton
  7872. * @param parentBone defines the parent (can be null if the bone is the root)
  7873. * @param localMatrix defines the local matrix
  7874. * @param restPose defines the rest pose matrix
  7875. * @param baseMatrix defines the base matrix
  7876. * @param index defines index of the bone in the hiearchy
  7877. */
  7878. constructor(
  7879. /**
  7880. * defines the bone name
  7881. */
  7882. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  7883. /**
  7884. * Gets the current object class name.
  7885. * @return the class name
  7886. */
  7887. getClassName(): string;
  7888. /**
  7889. * Gets the parent skeleton
  7890. * @returns a skeleton
  7891. */
  7892. getSkeleton(): Skeleton;
  7893. /**
  7894. * Gets parent bone
  7895. * @returns a bone or null if the bone is the root of the bone hierarchy
  7896. */
  7897. getParent(): Nullable<Bone>;
  7898. /**
  7899. * Returns an array containing the root bones
  7900. * @returns an array containing the root bones
  7901. */
  7902. getChildren(): Array<Bone>;
  7903. /**
  7904. * Sets the parent bone
  7905. * @param parent defines the parent (can be null if the bone is the root)
  7906. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7907. */
  7908. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  7909. /**
  7910. * Gets the local matrix
  7911. * @returns a matrix
  7912. */
  7913. getLocalMatrix(): Matrix;
  7914. /**
  7915. * Gets the base matrix (initial matrix which remains unchanged)
  7916. * @returns a matrix
  7917. */
  7918. getBaseMatrix(): Matrix;
  7919. /**
  7920. * Gets the rest pose matrix
  7921. * @returns a matrix
  7922. */
  7923. getRestPose(): Matrix;
  7924. /**
  7925. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  7926. */
  7927. getWorldMatrix(): Matrix;
  7928. /**
  7929. * Sets the local matrix to rest pose matrix
  7930. */
  7931. returnToRest(): void;
  7932. /**
  7933. * Gets the inverse of the absolute transform matrix.
  7934. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  7935. * @returns a matrix
  7936. */
  7937. getInvertedAbsoluteTransform(): Matrix;
  7938. /**
  7939. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  7940. * @returns a matrix
  7941. */
  7942. getAbsoluteTransform(): Matrix;
  7943. /**
  7944. * Links with the given transform node.
  7945. * The local matrix of this bone is copied from the transform node every frame.
  7946. * @param transformNode defines the transform node to link to
  7947. */
  7948. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  7949. /** Gets or sets current position (in local space) */
  7950. position: Vector3;
  7951. /** Gets or sets current rotation (in local space) */
  7952. rotation: Vector3;
  7953. /** Gets or sets current rotation quaternion (in local space) */
  7954. rotationQuaternion: Quaternion;
  7955. /** Gets or sets current scaling (in local space) */
  7956. scaling: Vector3;
  7957. /**
  7958. * Gets the animation properties override
  7959. */
  7960. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  7961. private _decompose;
  7962. private _compose;
  7963. /**
  7964. * Update the base and local matrices
  7965. * @param matrix defines the new base or local matrix
  7966. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7967. * @param updateLocalMatrix defines if the local matrix should be updated
  7968. */
  7969. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  7970. /** @hidden */ updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  7971. /**
  7972. * Flag the bone as dirty (Forcing it to update everything)
  7973. */
  7974. markAsDirty(): void;
  7975. private _markAsDirtyAndCompose;
  7976. private _markAsDirtyAndDecompose;
  7977. /**
  7978. * Translate the bone in local or world space
  7979. * @param vec The amount to translate the bone
  7980. * @param space The space that the translation is in
  7981. * @param mesh The mesh that this bone is attached to. This is only used in world space
  7982. */
  7983. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  7984. /**
  7985. * Set the postion of the bone in local or world space
  7986. * @param position The position to set the bone
  7987. * @param space The space that the position is in
  7988. * @param mesh The mesh that this bone is attached to. This is only used in world space
  7989. */
  7990. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  7991. /**
  7992. * Set the absolute position of the bone (world space)
  7993. * @param position The position to set the bone
  7994. * @param mesh The mesh that this bone is attached to
  7995. */
  7996. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  7997. /**
  7998. * Scale the bone on the x, y and z axes (in local space)
  7999. * @param x The amount to scale the bone on the x axis
  8000. * @param y The amount to scale the bone on the y axis
  8001. * @param z The amount to scale the bone on the z axis
  8002. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8003. */
  8004. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8005. /**
  8006. * Set the bone scaling in local space
  8007. * @param scale defines the scaling vector
  8008. */
  8009. setScale(scale: Vector3): void;
  8010. /**
  8011. * Gets the current scaling in local space
  8012. * @returns the current scaling vector
  8013. */
  8014. getScale(): Vector3;
  8015. /**
  8016. * Gets the current scaling in local space and stores it in a target vector
  8017. * @param result defines the target vector
  8018. */
  8019. getScaleToRef(result: Vector3): void;
  8020. /**
  8021. * Set the yaw, pitch, and roll of the bone in local or world space
  8022. * @param yaw The rotation of the bone on the y axis
  8023. * @param pitch The rotation of the bone on the x axis
  8024. * @param roll The rotation of the bone on the z axis
  8025. * @param space The space that the axes of rotation are in
  8026. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8027. */
  8028. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8029. /**
  8030. * Add a rotation to the bone on an axis in local or world space
  8031. * @param axis The axis to rotate the bone on
  8032. * @param amount The amount to rotate the bone
  8033. * @param space The space that the axis is in
  8034. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8035. */
  8036. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8037. /**
  8038. * Set the rotation of the bone to a particular axis angle in local or world space
  8039. * @param axis The axis to rotate the bone on
  8040. * @param angle The angle that the bone should be rotated to
  8041. * @param space The space that the axis is in
  8042. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8043. */
  8044. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8045. /**
  8046. * Set the euler rotation of the bone in local of world space
  8047. * @param rotation The euler rotation that the bone should be set to
  8048. * @param space The space that the rotation is in
  8049. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8050. */
  8051. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8052. /**
  8053. * Set the quaternion rotation of the bone in local of world space
  8054. * @param quat The quaternion rotation that the bone should be set to
  8055. * @param space The space that the rotation is in
  8056. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8057. */
  8058. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8059. /**
  8060. * Set the rotation matrix of the bone in local of world space
  8061. * @param rotMat The rotation matrix that the bone should be set to
  8062. * @param space The space that the rotation is in
  8063. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8064. */
  8065. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8066. private _rotateWithMatrix;
  8067. private _getNegativeRotationToRef;
  8068. /**
  8069. * Get the position of the bone in local or world space
  8070. * @param space The space that the returned position is in
  8071. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8072. * @returns The position of the bone
  8073. */
  8074. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8075. /**
  8076. * Copy the position of the bone to a vector3 in local or world space
  8077. * @param space The space that the returned position is in
  8078. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8079. * @param result The vector3 to copy the position to
  8080. */
  8081. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8082. /**
  8083. * Get the absolute position of the bone (world space)
  8084. * @param mesh The mesh that this bone is attached to
  8085. * @returns The absolute position of the bone
  8086. */
  8087. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8088. /**
  8089. * Copy the absolute position of the bone (world space) to the result param
  8090. * @param mesh The mesh that this bone is attached to
  8091. * @param result The vector3 to copy the absolute position to
  8092. */
  8093. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8094. /**
  8095. * Compute the absolute transforms of this bone and its children
  8096. */
  8097. computeAbsoluteTransforms(): void;
  8098. /**
  8099. * Get the world direction from an axis that is in the local space of the bone
  8100. * @param localAxis The local direction that is used to compute the world direction
  8101. * @param mesh The mesh that this bone is attached to
  8102. * @returns The world direction
  8103. */
  8104. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8105. /**
  8106. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8107. * @param localAxis The local direction that is used to compute the world direction
  8108. * @param mesh The mesh that this bone is attached to
  8109. * @param result The vector3 that the world direction will be copied to
  8110. */
  8111. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8112. /**
  8113. * Get the euler rotation of the bone in local or world space
  8114. * @param space The space that the rotation should be in
  8115. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8116. * @returns The euler rotation
  8117. */
  8118. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8119. /**
  8120. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8121. * @param space The space that the rotation should be in
  8122. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8123. * @param result The vector3 that the rotation should be copied to
  8124. */
  8125. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8126. /**
  8127. * Get the quaternion rotation of the bone in either local or world space
  8128. * @param space The space that the rotation should be in
  8129. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8130. * @returns The quaternion rotation
  8131. */
  8132. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8133. /**
  8134. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8135. * @param space The space that the rotation should be in
  8136. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8137. * @param result The quaternion that the rotation should be copied to
  8138. */
  8139. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8140. /**
  8141. * Get the rotation matrix of the bone in local or world space
  8142. * @param space The space that the rotation should be in
  8143. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8144. * @returns The rotation matrix
  8145. */
  8146. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8147. /**
  8148. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8149. * @param space The space that the rotation should be in
  8150. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8151. * @param result The quaternion that the rotation should be copied to
  8152. */
  8153. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8154. /**
  8155. * Get the world position of a point that is in the local space of the bone
  8156. * @param position The local position
  8157. * @param mesh The mesh that this bone is attached to
  8158. * @returns The world position
  8159. */
  8160. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8161. /**
  8162. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8163. * @param position The local position
  8164. * @param mesh The mesh that this bone is attached to
  8165. * @param result The vector3 that the world position should be copied to
  8166. */
  8167. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8168. /**
  8169. * Get the local position of a point that is in world space
  8170. * @param position The world position
  8171. * @param mesh The mesh that this bone is attached to
  8172. * @returns The local position
  8173. */
  8174. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8175. /**
  8176. * Get the local position of a point that is in world space and copy it to the result param
  8177. * @param position The world position
  8178. * @param mesh The mesh that this bone is attached to
  8179. * @param result The vector3 that the local position should be copied to
  8180. */
  8181. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8182. }
  8183. }
  8184. declare module BABYLON {
  8185. /**
  8186. * Enum that determines the text-wrapping mode to use.
  8187. */
  8188. export enum InspectableType {
  8189. /**
  8190. * Checkbox for booleans
  8191. */
  8192. Checkbox = 0,
  8193. /**
  8194. * Sliders for numbers
  8195. */
  8196. Slider = 1,
  8197. /**
  8198. * Vector3
  8199. */
  8200. Vector3 = 2,
  8201. /**
  8202. * Quaternions
  8203. */
  8204. Quaternion = 3,
  8205. /**
  8206. * Color3
  8207. */
  8208. Color3 = 4
  8209. }
  8210. /**
  8211. * Interface used to define custom inspectable properties.
  8212. * This interface is used by the inspector to display custom property grids
  8213. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8214. */
  8215. export interface IInspectable {
  8216. /**
  8217. * Gets the label to display
  8218. */
  8219. label: string;
  8220. /**
  8221. * Gets the name of the property to edit
  8222. */
  8223. propertyName: string;
  8224. /**
  8225. * Gets the type of the editor to use
  8226. */
  8227. type: InspectableType;
  8228. /**
  8229. * Gets the minimum value of the property when using in "slider" mode
  8230. */
  8231. min?: number;
  8232. /**
  8233. * Gets the maximum value of the property when using in "slider" mode
  8234. */
  8235. max?: number;
  8236. /**
  8237. * Gets the setp to use when using in "slider" mode
  8238. */
  8239. step?: number;
  8240. }
  8241. }
  8242. declare module BABYLON {
  8243. /**
  8244. * Class for creating a cube texture
  8245. */
  8246. export class CubeTexture extends BaseTexture {
  8247. private _delayedOnLoad;
  8248. /**
  8249. * The url of the texture
  8250. */
  8251. url: string;
  8252. /**
  8253. * Gets or sets the center of the bounding box associated with the cube texture.
  8254. * It must define where the camera used to render the texture was set
  8255. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8256. */
  8257. boundingBoxPosition: Vector3;
  8258. private _boundingBoxSize;
  8259. /**
  8260. * Gets or sets the size of the bounding box associated with the cube texture
  8261. * When defined, the cubemap will switch to local mode
  8262. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8263. * @example https://www.babylonjs-playground.com/#RNASML
  8264. */
  8265. /**
  8266. * Returns the bounding box size
  8267. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8268. */
  8269. boundingBoxSize: Vector3;
  8270. protected _rotationY: number;
  8271. /**
  8272. * Sets texture matrix rotation angle around Y axis in radians.
  8273. */
  8274. /**
  8275. * Gets texture matrix rotation angle around Y axis radians.
  8276. */
  8277. rotationY: number;
  8278. /**
  8279. * Are mip maps generated for this texture or not.
  8280. */
  8281. readonly noMipmap: boolean;
  8282. private _noMipmap;
  8283. private _files;
  8284. private _extensions;
  8285. private _textureMatrix;
  8286. private _format;
  8287. private _createPolynomials;
  8288. /** @hidden */ prefiltered: boolean;
  8289. /**
  8290. * Creates a cube texture from an array of image urls
  8291. * @param files defines an array of image urls
  8292. * @param scene defines the hosting scene
  8293. * @param noMipmap specifies if mip maps are not used
  8294. * @returns a cube texture
  8295. */
  8296. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8297. /**
  8298. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8299. * @param url defines the url of the prefiltered texture
  8300. * @param scene defines the scene the texture is attached to
  8301. * @param forcedExtension defines the extension of the file if different from the url
  8302. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8303. * @return the prefiltered texture
  8304. */
  8305. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8306. /**
  8307. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8308. * as prefiltered data.
  8309. * @param rootUrl defines the url of the texture or the root name of the six images
  8310. * @param scene defines the scene the texture is attached to
  8311. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8312. * @param noMipmap defines if mipmaps should be created or not
  8313. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8314. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8315. * @param onError defines a callback triggered in case of error during load
  8316. * @param format defines the internal format to use for the texture once loaded
  8317. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8318. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8319. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8320. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8321. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8322. * @return the cube texture
  8323. */
  8324. 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);
  8325. /**
  8326. * Get the current class name of the texture useful for serialization or dynamic coding.
  8327. * @returns "CubeTexture"
  8328. */
  8329. getClassName(): string;
  8330. /**
  8331. * Update the url (and optional buffer) of this texture if url was null during construction.
  8332. * @param url the url of the texture
  8333. * @param forcedExtension defines the extension to use
  8334. * @param onLoad callback called when the texture is loaded (defaults to null)
  8335. */
  8336. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8337. /**
  8338. * Delays loading of the cube texture
  8339. * @param forcedExtension defines the extension to use
  8340. */
  8341. delayLoad(forcedExtension?: string): void;
  8342. /**
  8343. * Returns the reflection texture matrix
  8344. * @returns the reflection texture matrix
  8345. */
  8346. getReflectionTextureMatrix(): Matrix;
  8347. /**
  8348. * Sets the reflection texture matrix
  8349. * @param value Reflection texture matrix
  8350. */
  8351. setReflectionTextureMatrix(value: Matrix): void;
  8352. /**
  8353. * Parses text to create a cube texture
  8354. * @param parsedTexture define the serialized text to read from
  8355. * @param scene defines the hosting scene
  8356. * @param rootUrl defines the root url of the cube texture
  8357. * @returns a cube texture
  8358. */
  8359. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8360. /**
  8361. * Makes a clone, or deep copy, of the cube texture
  8362. * @returns a new cube texture
  8363. */
  8364. clone(): CubeTexture;
  8365. }
  8366. }
  8367. declare module BABYLON {
  8368. /** @hidden */
  8369. export var postprocessVertexShader: {
  8370. name: string;
  8371. shader: string;
  8372. };
  8373. }
  8374. declare module BABYLON {
  8375. /**
  8376. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8377. * This is the base of the follow, arc rotate cameras and Free camera
  8378. * @see http://doc.babylonjs.com/features/cameras
  8379. */
  8380. export class TargetCamera extends Camera {
  8381. private static _RigCamTransformMatrix;
  8382. private static _TargetTransformMatrix;
  8383. private static _TargetFocalPoint;
  8384. /**
  8385. * Define the current direction the camera is moving to
  8386. */
  8387. cameraDirection: Vector3;
  8388. /**
  8389. * Define the current rotation the camera is rotating to
  8390. */
  8391. cameraRotation: Vector2;
  8392. /**
  8393. * When set, the up vector of the camera will be updated by the rotation of the camera
  8394. */
  8395. updateUpVectorFromRotation: boolean;
  8396. private _tmpQuaternion;
  8397. /**
  8398. * Define the current rotation of the camera
  8399. */
  8400. rotation: Vector3;
  8401. /**
  8402. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8403. */
  8404. rotationQuaternion: Quaternion;
  8405. /**
  8406. * Define the current speed of the camera
  8407. */
  8408. speed: number;
  8409. /**
  8410. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8411. * around all axis.
  8412. */
  8413. noRotationConstraint: boolean;
  8414. /**
  8415. * Define the current target of the camera as an object or a position.
  8416. */
  8417. lockedTarget: any;
  8418. /** @hidden */ currentTarget: Vector3;
  8419. /** @hidden */ initialFocalDistance: number;
  8420. /** @hidden */ viewMatrix: Matrix;
  8421. /** @hidden */ camMatrix: Matrix;
  8422. /** @hidden */ cameraTransformMatrix: Matrix;
  8423. /** @hidden */ cameraRotationMatrix: Matrix;
  8424. /** @hidden */ referencePoint: Vector3;
  8425. /** @hidden */ transformedReferencePoint: Vector3;
  8426. protected _globalCurrentTarget: Vector3;
  8427. protected _globalCurrentUpVector: Vector3;
  8428. /** @hidden */ reset: () => void;
  8429. private _defaultUp;
  8430. /**
  8431. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8432. * This is the base of the follow, arc rotate cameras and Free camera
  8433. * @see http://doc.babylonjs.com/features/cameras
  8434. * @param name Defines the name of the camera in the scene
  8435. * @param position Defines the start position of the camera in the scene
  8436. * @param scene Defines the scene the camera belongs to
  8437. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8438. */
  8439. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8440. /**
  8441. * Gets the position in front of the camera at a given distance.
  8442. * @param distance The distance from the camera we want the position to be
  8443. * @returns the position
  8444. */
  8445. getFrontPosition(distance: number): Vector3;
  8446. /** @hidden */ getLockedTargetPosition(): Nullable<Vector3>;
  8447. private _storedPosition;
  8448. private _storedRotation;
  8449. private _storedRotationQuaternion;
  8450. /**
  8451. * Store current camera state of the camera (fov, position, rotation, etc..)
  8452. * @returns the camera
  8453. */
  8454. storeState(): Camera;
  8455. /**
  8456. * Restored camera state. You must call storeState() first
  8457. * @returns whether it was successful or not
  8458. * @hidden
  8459. */ restoreStateValues(): boolean;
  8460. /** @hidden */ initCache(): void;
  8461. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  8462. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  8463. /** @hidden */ computeLocalCameraSpeed(): number;
  8464. /**
  8465. * Defines the target the camera should look at.
  8466. * This will automatically adapt alpha beta and radius to fit within the new target.
  8467. * @param target Defines the new target as a Vector or a mesh
  8468. */
  8469. setTarget(target: Vector3): void;
  8470. /**
  8471. * Return the current target position of the camera. This value is expressed in local space.
  8472. * @returns the target position
  8473. */
  8474. getTarget(): Vector3;
  8475. /** @hidden */ decideIfNeedsToMove(): boolean;
  8476. /** @hidden */ updatePosition(): void;
  8477. /** @hidden */ checkInputs(): void;
  8478. protected _updateCameraRotationMatrix(): void;
  8479. /**
  8480. * 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)
  8481. * @returns the current camera
  8482. */
  8483. private _rotateUpVectorWithCameraRotationMatrix;
  8484. private _cachedRotationZ;
  8485. private _cachedQuaternionRotationZ;
  8486. /** @hidden */ getViewMatrix(): Matrix;
  8487. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8488. /**
  8489. * @hidden
  8490. */
  8491. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8492. /**
  8493. * @hidden
  8494. */ updateRigCameras(): void;
  8495. private _getRigCamPositionAndTarget;
  8496. /**
  8497. * Gets the current object class name.
  8498. * @return the class name
  8499. */
  8500. getClassName(): string;
  8501. }
  8502. }
  8503. declare module BABYLON {
  8504. /**
  8505. * @ignore
  8506. * This is a list of all the different input types that are available in the application.
  8507. * Fo instance: ArcRotateCameraGamepadInput...
  8508. */
  8509. export var CameraInputTypes: {};
  8510. /**
  8511. * This is the contract to implement in order to create a new input class.
  8512. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8513. */
  8514. export interface ICameraInput<TCamera extends Camera> {
  8515. /**
  8516. * Defines the camera the input is attached to.
  8517. */
  8518. camera: Nullable<TCamera>;
  8519. /**
  8520. * Gets the class name of the current intput.
  8521. * @returns the class name
  8522. */
  8523. getClassName(): string;
  8524. /**
  8525. * Get the friendly name associated with the input class.
  8526. * @returns the input friendly name
  8527. */
  8528. getSimpleName(): string;
  8529. /**
  8530. * Attach the input controls to a specific dom element to get the input from.
  8531. * @param element Defines the element the controls should be listened from
  8532. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8533. */
  8534. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8535. /**
  8536. * Detach the current controls from the specified dom element.
  8537. * @param element Defines the element to stop listening the inputs from
  8538. */
  8539. detachControl(element: Nullable<HTMLElement>): void;
  8540. /**
  8541. * Update the current camera state depending on the inputs that have been used this frame.
  8542. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8543. */
  8544. checkInputs?: () => void;
  8545. }
  8546. /**
  8547. * Represents a map of input types to input instance or input index to input instance.
  8548. */
  8549. export interface CameraInputsMap<TCamera extends Camera> {
  8550. /**
  8551. * Accessor to the input by input type.
  8552. */
  8553. [name: string]: ICameraInput<TCamera>;
  8554. /**
  8555. * Accessor to the input by input index.
  8556. */
  8557. [idx: number]: ICameraInput<TCamera>;
  8558. }
  8559. /**
  8560. * This represents the input manager used within a camera.
  8561. * It helps dealing with all the different kind of input attached to a camera.
  8562. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8563. */
  8564. export class CameraInputsManager<TCamera extends Camera> {
  8565. /**
  8566. * Defines the list of inputs attahed to the camera.
  8567. */
  8568. attached: CameraInputsMap<TCamera>;
  8569. /**
  8570. * Defines the dom element the camera is collecting inputs from.
  8571. * This is null if the controls have not been attached.
  8572. */
  8573. attachedElement: Nullable<HTMLElement>;
  8574. /**
  8575. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8576. */
  8577. noPreventDefault: boolean;
  8578. /**
  8579. * Defined the camera the input manager belongs to.
  8580. */
  8581. camera: TCamera;
  8582. /**
  8583. * Update the current camera state depending on the inputs that have been used this frame.
  8584. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8585. */
  8586. checkInputs: () => void;
  8587. /**
  8588. * Instantiate a new Camera Input Manager.
  8589. * @param camera Defines the camera the input manager blongs to
  8590. */
  8591. constructor(camera: TCamera);
  8592. /**
  8593. * Add an input method to a camera
  8594. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8595. * @param input camera input method
  8596. */
  8597. add(input: ICameraInput<TCamera>): void;
  8598. /**
  8599. * Remove a specific input method from a camera
  8600. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8601. * @param inputToRemove camera input method
  8602. */
  8603. remove(inputToRemove: ICameraInput<TCamera>): void;
  8604. /**
  8605. * Remove a specific input type from a camera
  8606. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8607. * @param inputType the type of the input to remove
  8608. */
  8609. removeByType(inputType: string): void;
  8610. private _addCheckInputs;
  8611. /**
  8612. * Attach the input controls to the currently attached dom element to listen the events from.
  8613. * @param input Defines the input to attach
  8614. */
  8615. attachInput(input: ICameraInput<TCamera>): void;
  8616. /**
  8617. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8618. * @param element Defines the dom element to collect the events from
  8619. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8620. */
  8621. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8622. /**
  8623. * Detach the current manager inputs controls from a specific dom element.
  8624. * @param element Defines the dom element to collect the events from
  8625. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8626. */
  8627. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8628. /**
  8629. * Rebuild the dynamic inputCheck function from the current list of
  8630. * defined inputs in the manager.
  8631. */
  8632. rebuildInputCheck(): void;
  8633. /**
  8634. * Remove all attached input methods from a camera
  8635. */
  8636. clear(): void;
  8637. /**
  8638. * Serialize the current input manager attached to a camera.
  8639. * This ensures than once parsed,
  8640. * the input associated to the camera will be identical to the current ones
  8641. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8642. */
  8643. serialize(serializedCamera: any): void;
  8644. /**
  8645. * Parses an input manager serialized JSON to restore the previous list of inputs
  8646. * and states associated to a camera.
  8647. * @param parsedCamera Defines the JSON to parse
  8648. */
  8649. parse(parsedCamera: any): void;
  8650. }
  8651. }
  8652. declare module BABYLON {
  8653. /**
  8654. * Gather the list of keyboard event types as constants.
  8655. */
  8656. export class KeyboardEventTypes {
  8657. /**
  8658. * The keydown event is fired when a key becomes active (pressed).
  8659. */
  8660. static readonly KEYDOWN: number;
  8661. /**
  8662. * The keyup event is fired when a key has been released.
  8663. */
  8664. static readonly KEYUP: number;
  8665. }
  8666. /**
  8667. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8668. */
  8669. export class KeyboardInfo {
  8670. /**
  8671. * Defines the type of event (KeyboardEventTypes)
  8672. */
  8673. type: number;
  8674. /**
  8675. * Defines the related dom event
  8676. */
  8677. event: KeyboardEvent;
  8678. /**
  8679. * Instantiates a new keyboard info.
  8680. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8681. * @param type Defines the type of event (KeyboardEventTypes)
  8682. * @param event Defines the related dom event
  8683. */
  8684. constructor(
  8685. /**
  8686. * Defines the type of event (KeyboardEventTypes)
  8687. */
  8688. type: number,
  8689. /**
  8690. * Defines the related dom event
  8691. */
  8692. event: KeyboardEvent);
  8693. }
  8694. /**
  8695. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8696. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8697. */
  8698. export class KeyboardInfoPre extends KeyboardInfo {
  8699. /**
  8700. * Defines the type of event (KeyboardEventTypes)
  8701. */
  8702. type: number;
  8703. /**
  8704. * Defines the related dom event
  8705. */
  8706. event: KeyboardEvent;
  8707. /**
  8708. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8709. */
  8710. skipOnPointerObservable: boolean;
  8711. /**
  8712. * Instantiates a new keyboard pre info.
  8713. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8714. * @param type Defines the type of event (KeyboardEventTypes)
  8715. * @param event Defines the related dom event
  8716. */
  8717. constructor(
  8718. /**
  8719. * Defines the type of event (KeyboardEventTypes)
  8720. */
  8721. type: number,
  8722. /**
  8723. * Defines the related dom event
  8724. */
  8725. event: KeyboardEvent);
  8726. }
  8727. }
  8728. declare module BABYLON {
  8729. /**
  8730. * Manage the keyboard inputs to control the movement of a free camera.
  8731. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8732. */
  8733. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8734. /**
  8735. * Defines the camera the input is attached to.
  8736. */
  8737. camera: FreeCamera;
  8738. /**
  8739. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8740. */
  8741. keysUp: number[];
  8742. /**
  8743. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8744. */
  8745. keysDown: number[];
  8746. /**
  8747. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8748. */
  8749. keysLeft: number[];
  8750. /**
  8751. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8752. */
  8753. keysRight: number[];
  8754. private _keys;
  8755. private _onCanvasBlurObserver;
  8756. private _onKeyboardObserver;
  8757. private _engine;
  8758. private _scene;
  8759. /**
  8760. * Attach the input controls to a specific dom element to get the input from.
  8761. * @param element Defines the element the controls should be listened from
  8762. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8763. */
  8764. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8765. /**
  8766. * Detach the current controls from the specified dom element.
  8767. * @param element Defines the element to stop listening the inputs from
  8768. */
  8769. detachControl(element: Nullable<HTMLElement>): void;
  8770. /**
  8771. * Update the current camera state depending on the inputs that have been used this frame.
  8772. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8773. */
  8774. checkInputs(): void;
  8775. /**
  8776. * Gets the class name of the current intput.
  8777. * @returns the class name
  8778. */
  8779. getClassName(): string;
  8780. /** @hidden */ onLostFocus(): void;
  8781. /**
  8782. * Get the friendly name associated with the input class.
  8783. * @returns the input friendly name
  8784. */
  8785. getSimpleName(): string;
  8786. }
  8787. }
  8788. declare module BABYLON {
  8789. /**
  8790. * Interface describing all the common properties and methods a shadow light needs to implement.
  8791. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8792. * as well as binding the different shadow properties to the effects.
  8793. */
  8794. export interface IShadowLight extends Light {
  8795. /**
  8796. * The light id in the scene (used in scene.findLighById for instance)
  8797. */
  8798. id: string;
  8799. /**
  8800. * The position the shdow will be casted from.
  8801. */
  8802. position: Vector3;
  8803. /**
  8804. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8805. */
  8806. direction: Vector3;
  8807. /**
  8808. * The transformed position. Position of the light in world space taking parenting in account.
  8809. */
  8810. transformedPosition: Vector3;
  8811. /**
  8812. * The transformed direction. Direction of the light in world space taking parenting in account.
  8813. */
  8814. transformedDirection: Vector3;
  8815. /**
  8816. * The friendly name of the light in the scene.
  8817. */
  8818. name: string;
  8819. /**
  8820. * Defines the shadow projection clipping minimum z value.
  8821. */
  8822. shadowMinZ: number;
  8823. /**
  8824. * Defines the shadow projection clipping maximum z value.
  8825. */
  8826. shadowMaxZ: number;
  8827. /**
  8828. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8829. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8830. */
  8831. computeTransformedInformation(): boolean;
  8832. /**
  8833. * Gets the scene the light belongs to.
  8834. * @returns The scene
  8835. */
  8836. getScene(): Scene;
  8837. /**
  8838. * Callback defining a custom Projection Matrix Builder.
  8839. * This can be used to override the default projection matrix computation.
  8840. */
  8841. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8842. /**
  8843. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8844. * @param matrix The materix to updated with the projection information
  8845. * @param viewMatrix The transform matrix of the light
  8846. * @param renderList The list of mesh to render in the map
  8847. * @returns The current light
  8848. */
  8849. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8850. /**
  8851. * Gets the current depth scale used in ESM.
  8852. * @returns The scale
  8853. */
  8854. getDepthScale(): number;
  8855. /**
  8856. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8857. * @returns true if a cube texture needs to be use
  8858. */
  8859. needCube(): boolean;
  8860. /**
  8861. * Detects if the projection matrix requires to be recomputed this frame.
  8862. * @returns true if it requires to be recomputed otherwise, false.
  8863. */
  8864. needProjectionMatrixCompute(): boolean;
  8865. /**
  8866. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8867. */
  8868. forceProjectionMatrixCompute(): void;
  8869. /**
  8870. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8871. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8872. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8873. */
  8874. getShadowDirection(faceIndex?: number): Vector3;
  8875. /**
  8876. * Gets the minZ used for shadow according to both the scene and the light.
  8877. * @param activeCamera The camera we are returning the min for
  8878. * @returns the depth min z
  8879. */
  8880. getDepthMinZ(activeCamera: Camera): number;
  8881. /**
  8882. * Gets the maxZ used for shadow according to both the scene and the light.
  8883. * @param activeCamera The camera we are returning the max for
  8884. * @returns the depth max z
  8885. */
  8886. getDepthMaxZ(activeCamera: Camera): number;
  8887. }
  8888. /**
  8889. * Base implementation IShadowLight
  8890. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8891. */
  8892. export abstract class ShadowLight extends Light implements IShadowLight {
  8893. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8894. protected _position: Vector3;
  8895. protected _setPosition(value: Vector3): void;
  8896. /**
  8897. * Sets the position the shadow will be casted from. Also use as the light position for both
  8898. * point and spot lights.
  8899. */
  8900. /**
  8901. * Sets the position the shadow will be casted from. Also use as the light position for both
  8902. * point and spot lights.
  8903. */
  8904. position: Vector3;
  8905. protected _direction: Vector3;
  8906. protected _setDirection(value: Vector3): void;
  8907. /**
  8908. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8909. * Also use as the light direction on spot and directional lights.
  8910. */
  8911. /**
  8912. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8913. * Also use as the light direction on spot and directional lights.
  8914. */
  8915. direction: Vector3;
  8916. private _shadowMinZ;
  8917. /**
  8918. * Gets the shadow projection clipping minimum z value.
  8919. */
  8920. /**
  8921. * Sets the shadow projection clipping minimum z value.
  8922. */
  8923. shadowMinZ: number;
  8924. private _shadowMaxZ;
  8925. /**
  8926. * Sets the shadow projection clipping maximum z value.
  8927. */
  8928. /**
  8929. * Gets the shadow projection clipping maximum z value.
  8930. */
  8931. shadowMaxZ: number;
  8932. /**
  8933. * Callback defining a custom Projection Matrix Builder.
  8934. * This can be used to override the default projection matrix computation.
  8935. */
  8936. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8937. /**
  8938. * The transformed position. Position of the light in world space taking parenting in account.
  8939. */
  8940. transformedPosition: Vector3;
  8941. /**
  8942. * The transformed direction. Direction of the light in world space taking parenting in account.
  8943. */
  8944. transformedDirection: Vector3;
  8945. private _needProjectionMatrixCompute;
  8946. /**
  8947. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8948. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8949. */
  8950. computeTransformedInformation(): boolean;
  8951. /**
  8952. * Return the depth scale used for the shadow map.
  8953. * @returns the depth scale.
  8954. */
  8955. getDepthScale(): number;
  8956. /**
  8957. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8958. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8959. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8960. */
  8961. getShadowDirection(faceIndex?: number): Vector3;
  8962. /**
  8963. * Returns the ShadowLight absolute position in the World.
  8964. * @returns the position vector in world space
  8965. */
  8966. getAbsolutePosition(): Vector3;
  8967. /**
  8968. * Sets the ShadowLight direction toward the passed target.
  8969. * @param target The point to target in local space
  8970. * @returns the updated ShadowLight direction
  8971. */
  8972. setDirectionToTarget(target: Vector3): Vector3;
  8973. /**
  8974. * Returns the light rotation in euler definition.
  8975. * @returns the x y z rotation in local space.
  8976. */
  8977. getRotation(): Vector3;
  8978. /**
  8979. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8980. * @returns true if a cube texture needs to be use
  8981. */
  8982. needCube(): boolean;
  8983. /**
  8984. * Detects if the projection matrix requires to be recomputed this frame.
  8985. * @returns true if it requires to be recomputed otherwise, false.
  8986. */
  8987. needProjectionMatrixCompute(): boolean;
  8988. /**
  8989. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8990. */
  8991. forceProjectionMatrixCompute(): void;
  8992. /** @hidden */ initCache(): void;
  8993. /** @hidden */ isSynchronized(): boolean;
  8994. /**
  8995. * Computes the world matrix of the node
  8996. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8997. * @returns the world matrix
  8998. */
  8999. computeWorldMatrix(force?: boolean): Matrix;
  9000. /**
  9001. * Gets the minZ used for shadow according to both the scene and the light.
  9002. * @param activeCamera The camera we are returning the min for
  9003. * @returns the depth min z
  9004. */
  9005. getDepthMinZ(activeCamera: Camera): number;
  9006. /**
  9007. * Gets the maxZ used for shadow according to both the scene and the light.
  9008. * @param activeCamera The camera we are returning the max for
  9009. * @returns the depth max z
  9010. */
  9011. getDepthMaxZ(activeCamera: Camera): number;
  9012. /**
  9013. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9014. * @param matrix The materix to updated with the projection information
  9015. * @param viewMatrix The transform matrix of the light
  9016. * @param renderList The list of mesh to render in the map
  9017. * @returns The current light
  9018. */
  9019. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9020. }
  9021. }
  9022. declare module BABYLON {
  9023. /**
  9024. * "Static Class" containing the most commonly used helper while dealing with material for
  9025. * rendering purpose.
  9026. *
  9027. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9028. *
  9029. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9030. */
  9031. export class MaterialHelper {
  9032. /**
  9033. * Bind the current view position to an effect.
  9034. * @param effect The effect to be bound
  9035. * @param scene The scene the eyes position is used from
  9036. */
  9037. static BindEyePosition(effect: Effect, scene: Scene): void;
  9038. /**
  9039. * Helps preparing the defines values about the UVs in used in the effect.
  9040. * UVs are shared as much as we can accross channels in the shaders.
  9041. * @param texture The texture we are preparing the UVs for
  9042. * @param defines The defines to update
  9043. * @param key The channel key "diffuse", "specular"... used in the shader
  9044. */
  9045. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9046. /**
  9047. * Binds a texture matrix value to its corrsponding uniform
  9048. * @param texture The texture to bind the matrix for
  9049. * @param uniformBuffer The uniform buffer receivin the data
  9050. * @param key The channel key "diffuse", "specular"... used in the shader
  9051. */
  9052. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9053. /**
  9054. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9055. * @param mesh defines the current mesh
  9056. * @param scene defines the current scene
  9057. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9058. * @param pointsCloud defines if point cloud rendering has to be turned on
  9059. * @param fogEnabled defines if fog has to be turned on
  9060. * @param alphaTest defines if alpha testing has to be turned on
  9061. * @param defines defines the current list of defines
  9062. */
  9063. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9064. /**
  9065. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9066. * @param scene defines the current scene
  9067. * @param engine defines the current engine
  9068. * @param defines specifies the list of active defines
  9069. * @param useInstances defines if instances have to be turned on
  9070. * @param useClipPlane defines if clip plane have to be turned on
  9071. */
  9072. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9073. /**
  9074. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9075. * @param mesh The mesh containing the geometry data we will draw
  9076. * @param defines The defines to update
  9077. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9078. * @param useBones Precise whether bones should be used or not (override mesh info)
  9079. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9080. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9081. * @returns false if defines are considered not dirty and have not been checked
  9082. */
  9083. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9084. /**
  9085. * Prepares the defines related to multiview
  9086. * @param scene The scene we are intending to draw
  9087. * @param defines The defines to update
  9088. */
  9089. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9090. /**
  9091. * Prepares the defines related to the light information passed in parameter
  9092. * @param scene The scene we are intending to draw
  9093. * @param mesh The mesh the effect is compiling for
  9094. * @param defines The defines to update
  9095. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9096. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9097. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9098. * @returns true if normals will be required for the rest of the effect
  9099. */
  9100. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9101. /**
  9102. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9103. * that won t be acctive due to defines being turned off.
  9104. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9105. * @param samplersList The samplers list
  9106. * @param defines The defines helping in the list generation
  9107. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9108. */
  9109. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9110. /**
  9111. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9112. * @param defines The defines to update while falling back
  9113. * @param fallbacks The authorized effect fallbacks
  9114. * @param maxSimultaneousLights The maximum number of lights allowed
  9115. * @param rank the current rank of the Effect
  9116. * @returns The newly affected rank
  9117. */
  9118. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9119. /**
  9120. * Prepares the list of attributes required for morph targets according to the effect defines.
  9121. * @param attribs The current list of supported attribs
  9122. * @param mesh The mesh to prepare the morph targets attributes for
  9123. * @param defines The current Defines of the effect
  9124. */
  9125. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9126. /**
  9127. * Prepares the list of attributes required for bones according to the effect defines.
  9128. * @param attribs The current list of supported attribs
  9129. * @param mesh The mesh to prepare the bones attributes for
  9130. * @param defines The current Defines of the effect
  9131. * @param fallbacks The current efffect fallback strategy
  9132. */
  9133. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9134. /**
  9135. * Prepares the list of attributes required for instances according to the effect defines.
  9136. * @param attribs The current list of supported attribs
  9137. * @param defines The current Defines of the effect
  9138. */
  9139. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9140. /**
  9141. * Binds the light shadow information to the effect for the given mesh.
  9142. * @param light The light containing the generator
  9143. * @param scene The scene the lights belongs to
  9144. * @param mesh The mesh we are binding the information to render
  9145. * @param lightIndex The light index in the effect used to render the mesh
  9146. * @param effect The effect we are binding the data to
  9147. */
  9148. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9149. /**
  9150. * Binds the light information to the effect.
  9151. * @param light The light containing the generator
  9152. * @param effect The effect we are binding the data to
  9153. * @param lightIndex The light index in the effect used to render
  9154. */
  9155. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9156. /**
  9157. * Binds the lights information from the scene to the effect for the given mesh.
  9158. * @param scene The scene the lights belongs to
  9159. * @param mesh The mesh we are binding the information to render
  9160. * @param effect The effect we are binding the data to
  9161. * @param defines The generated defines for the effect
  9162. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9163. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9164. */
  9165. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9166. private static _tempFogColor;
  9167. /**
  9168. * Binds the fog information from the scene to the effect for the given mesh.
  9169. * @param scene The scene the lights belongs to
  9170. * @param mesh The mesh we are binding the information to render
  9171. * @param effect The effect we are binding the data to
  9172. * @param linearSpace Defines if the fog effect is applied in linear space
  9173. */
  9174. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9175. /**
  9176. * Binds the bones information from the mesh to the effect.
  9177. * @param mesh The mesh we are binding the information to render
  9178. * @param effect The effect we are binding the data to
  9179. */
  9180. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9181. /**
  9182. * Binds the morph targets information from the mesh to the effect.
  9183. * @param abstractMesh The mesh we are binding the information to render
  9184. * @param effect The effect we are binding the data to
  9185. */
  9186. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9187. /**
  9188. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9189. * @param defines The generated defines used in the effect
  9190. * @param effect The effect we are binding the data to
  9191. * @param scene The scene we are willing to render with logarithmic scale for
  9192. */
  9193. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9194. /**
  9195. * Binds the clip plane information from the scene to the effect.
  9196. * @param scene The scene the clip plane information are extracted from
  9197. * @param effect The effect we are binding the data to
  9198. */
  9199. static BindClipPlane(effect: Effect, scene: Scene): void;
  9200. }
  9201. }
  9202. declare module BABYLON {
  9203. /** @hidden */
  9204. export var kernelBlurVaryingDeclaration: {
  9205. name: string;
  9206. shader: string;
  9207. };
  9208. }
  9209. declare module BABYLON {
  9210. /** @hidden */
  9211. export var kernelBlurFragment: {
  9212. name: string;
  9213. shader: string;
  9214. };
  9215. }
  9216. declare module BABYLON {
  9217. /** @hidden */
  9218. export var kernelBlurFragment2: {
  9219. name: string;
  9220. shader: string;
  9221. };
  9222. }
  9223. declare module BABYLON {
  9224. /** @hidden */
  9225. export var kernelBlurPixelShader: {
  9226. name: string;
  9227. shader: string;
  9228. };
  9229. }
  9230. declare module BABYLON {
  9231. /** @hidden */
  9232. export var kernelBlurVertex: {
  9233. name: string;
  9234. shader: string;
  9235. };
  9236. }
  9237. declare module BABYLON {
  9238. /** @hidden */
  9239. export var kernelBlurVertexShader: {
  9240. name: string;
  9241. shader: string;
  9242. };
  9243. }
  9244. declare module BABYLON {
  9245. /**
  9246. * The Blur Post Process which blurs an image based on a kernel and direction.
  9247. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9248. */
  9249. export class BlurPostProcess extends PostProcess {
  9250. /** The direction in which to blur the image. */
  9251. direction: Vector2;
  9252. private blockCompilation;
  9253. protected _kernel: number;
  9254. protected _idealKernel: number;
  9255. protected _packedFloat: boolean;
  9256. private _staticDefines;
  9257. /**
  9258. * Sets the length in pixels of the blur sample region
  9259. */
  9260. /**
  9261. * Gets the length in pixels of the blur sample region
  9262. */
  9263. kernel: number;
  9264. /**
  9265. * Sets wether or not the blur needs to unpack/repack floats
  9266. */
  9267. /**
  9268. * Gets wether or not the blur is unpacking/repacking floats
  9269. */
  9270. packedFloat: boolean;
  9271. /**
  9272. * Creates a new instance BlurPostProcess
  9273. * @param name The name of the effect.
  9274. * @param direction The direction in which to blur the image.
  9275. * @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.
  9276. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9277. * @param camera The camera to apply the render pass to.
  9278. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9279. * @param engine The engine which the post process will be applied. (default: current engine)
  9280. * @param reusable If the post process can be reused on the same frame. (default: false)
  9281. * @param textureType Type of textures used when performing the post process. (default: 0)
  9282. * @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)
  9283. */
  9284. constructor(name: string,
  9285. /** The direction in which to blur the image. */
  9286. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9287. /**
  9288. * Updates the effect with the current post process compile time values and recompiles the shader.
  9289. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9290. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9291. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9292. * @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
  9293. * @param onCompiled Called when the shader has been compiled.
  9294. * @param onError Called if there is an error when compiling a shader.
  9295. */
  9296. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9297. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9298. /**
  9299. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9300. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9301. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9302. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9303. * The gaps between physical kernels are compensated for in the weighting of the samples
  9304. * @param idealKernel Ideal blur kernel.
  9305. * @return Nearest best kernel.
  9306. */
  9307. protected _nearestBestKernel(idealKernel: number): number;
  9308. /**
  9309. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9310. * @param x The point on the Gaussian distribution to sample.
  9311. * @return the value of the Gaussian function at x.
  9312. */
  9313. protected _gaussianWeight(x: number): number;
  9314. /**
  9315. * Generates a string that can be used as a floating point number in GLSL.
  9316. * @param x Value to print.
  9317. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9318. * @return GLSL float string.
  9319. */
  9320. protected _glslFloat(x: number, decimalFigures?: number): string;
  9321. }
  9322. }
  9323. declare module BABYLON {
  9324. /** @hidden */
  9325. export var shadowMapPixelShader: {
  9326. name: string;
  9327. shader: string;
  9328. };
  9329. }
  9330. declare module BABYLON {
  9331. /** @hidden */
  9332. export var bonesDeclaration: {
  9333. name: string;
  9334. shader: string;
  9335. };
  9336. }
  9337. declare module BABYLON {
  9338. /** @hidden */
  9339. export var morphTargetsVertexGlobalDeclaration: {
  9340. name: string;
  9341. shader: string;
  9342. };
  9343. }
  9344. declare module BABYLON {
  9345. /** @hidden */
  9346. export var morphTargetsVertexDeclaration: {
  9347. name: string;
  9348. shader: string;
  9349. };
  9350. }
  9351. declare module BABYLON {
  9352. /** @hidden */
  9353. export var instancesDeclaration: {
  9354. name: string;
  9355. shader: string;
  9356. };
  9357. }
  9358. declare module BABYLON {
  9359. /** @hidden */
  9360. export var helperFunctions: {
  9361. name: string;
  9362. shader: string;
  9363. };
  9364. }
  9365. declare module BABYLON {
  9366. /** @hidden */
  9367. export var morphTargetsVertex: {
  9368. name: string;
  9369. shader: string;
  9370. };
  9371. }
  9372. declare module BABYLON {
  9373. /** @hidden */
  9374. export var instancesVertex: {
  9375. name: string;
  9376. shader: string;
  9377. };
  9378. }
  9379. declare module BABYLON {
  9380. /** @hidden */
  9381. export var bonesVertex: {
  9382. name: string;
  9383. shader: string;
  9384. };
  9385. }
  9386. declare module BABYLON {
  9387. /** @hidden */
  9388. export var shadowMapVertexShader: {
  9389. name: string;
  9390. shader: string;
  9391. };
  9392. }
  9393. declare module BABYLON {
  9394. /** @hidden */
  9395. export var depthBoxBlurPixelShader: {
  9396. name: string;
  9397. shader: string;
  9398. };
  9399. }
  9400. declare module BABYLON {
  9401. /**
  9402. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9403. */
  9404. export interface ICustomShaderOptions {
  9405. /**
  9406. * Gets or sets the custom shader name to use
  9407. */
  9408. shaderName: string;
  9409. /**
  9410. * The list of attribute names used in the shader
  9411. */
  9412. attributes?: string[];
  9413. /**
  9414. * The list of unifrom names used in the shader
  9415. */
  9416. uniforms?: string[];
  9417. /**
  9418. * The list of sampler names used in the shader
  9419. */
  9420. samplers?: string[];
  9421. /**
  9422. * The list of defines used in the shader
  9423. */
  9424. defines?: string[];
  9425. }
  9426. /**
  9427. * Interface to implement to create a shadow generator compatible with BJS.
  9428. */
  9429. export interface IShadowGenerator {
  9430. /**
  9431. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9432. * @returns The render target texture if present otherwise, null
  9433. */
  9434. getShadowMap(): Nullable<RenderTargetTexture>;
  9435. /**
  9436. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9437. * @returns The render target texture if the shadow map is present otherwise, null
  9438. */
  9439. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9440. /**
  9441. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9442. * @param subMesh The submesh we want to render in the shadow map
  9443. * @param useInstances Defines wether will draw in the map using instances
  9444. * @returns true if ready otherwise, false
  9445. */
  9446. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9447. /**
  9448. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9449. * @param defines Defines of the material we want to update
  9450. * @param lightIndex Index of the light in the enabled light list of the material
  9451. */
  9452. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9453. /**
  9454. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9455. * defined in the generator but impacting the effect).
  9456. * It implies the unifroms available on the materials are the standard BJS ones.
  9457. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9458. * @param effect The effect we are binfing the information for
  9459. */
  9460. bindShadowLight(lightIndex: string, effect: Effect): void;
  9461. /**
  9462. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9463. * (eq to shadow prjection matrix * light transform matrix)
  9464. * @returns The transform matrix used to create the shadow map
  9465. */
  9466. getTransformMatrix(): Matrix;
  9467. /**
  9468. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9469. * Cube and 2D textures for instance.
  9470. */
  9471. recreateShadowMap(): void;
  9472. /**
  9473. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9474. * @param onCompiled Callback triggered at the and of the effects compilation
  9475. * @param options Sets of optional options forcing the compilation with different modes
  9476. */
  9477. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9478. useInstances: boolean;
  9479. }>): void;
  9480. /**
  9481. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9482. * @param options Sets of optional options forcing the compilation with different modes
  9483. * @returns A promise that resolves when the compilation completes
  9484. */
  9485. forceCompilationAsync(options?: Partial<{
  9486. useInstances: boolean;
  9487. }>): Promise<void>;
  9488. /**
  9489. * Serializes the shadow generator setup to a json object.
  9490. * @returns The serialized JSON object
  9491. */
  9492. serialize(): any;
  9493. /**
  9494. * Disposes the Shadow map and related Textures and effects.
  9495. */
  9496. dispose(): void;
  9497. }
  9498. /**
  9499. * Default implementation IShadowGenerator.
  9500. * This is the main object responsible of generating shadows in the framework.
  9501. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9502. */
  9503. export class ShadowGenerator implements IShadowGenerator {
  9504. /**
  9505. * Shadow generator mode None: no filtering applied.
  9506. */
  9507. static readonly FILTER_NONE: number;
  9508. /**
  9509. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9510. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9511. */
  9512. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9513. /**
  9514. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9515. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9516. */
  9517. static readonly FILTER_POISSONSAMPLING: number;
  9518. /**
  9519. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9520. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9521. */
  9522. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9523. /**
  9524. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9525. * edge artifacts on steep falloff.
  9526. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9527. */
  9528. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9529. /**
  9530. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9531. * edge artifacts on steep falloff.
  9532. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9533. */
  9534. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9535. /**
  9536. * Shadow generator mode PCF: Percentage Closer Filtering
  9537. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9538. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9539. */
  9540. static readonly FILTER_PCF: number;
  9541. /**
  9542. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9543. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9544. * Contact Hardening
  9545. */
  9546. static readonly FILTER_PCSS: number;
  9547. /**
  9548. * Reserved for PCF and PCSS
  9549. * Highest Quality.
  9550. *
  9551. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9552. *
  9553. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9554. */
  9555. static readonly QUALITY_HIGH: number;
  9556. /**
  9557. * Reserved for PCF and PCSS
  9558. * Good tradeoff for quality/perf cross devices
  9559. *
  9560. * Execute PCF on a 3*3 kernel.
  9561. *
  9562. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9563. */
  9564. static readonly QUALITY_MEDIUM: number;
  9565. /**
  9566. * Reserved for PCF and PCSS
  9567. * The lowest quality but the fastest.
  9568. *
  9569. * Execute PCF on a 1*1 kernel.
  9570. *
  9571. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9572. */
  9573. static readonly QUALITY_LOW: number;
  9574. /** Gets or sets the custom shader name to use */
  9575. customShaderOptions: ICustomShaderOptions;
  9576. /**
  9577. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9578. */
  9579. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9580. /**
  9581. * Observable triggered before a mesh is rendered in the shadow map.
  9582. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9583. */
  9584. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9585. private _bias;
  9586. /**
  9587. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9588. */
  9589. /**
  9590. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9591. */
  9592. bias: number;
  9593. private _normalBias;
  9594. /**
  9595. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9596. */
  9597. /**
  9598. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9599. */
  9600. normalBias: number;
  9601. private _blurBoxOffset;
  9602. /**
  9603. * Gets the blur box offset: offset applied during the blur pass.
  9604. * Only useful if useKernelBlur = false
  9605. */
  9606. /**
  9607. * Sets the blur box offset: offset applied during the blur pass.
  9608. * Only useful if useKernelBlur = false
  9609. */
  9610. blurBoxOffset: number;
  9611. private _blurScale;
  9612. /**
  9613. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9614. * 2 means half of the size.
  9615. */
  9616. /**
  9617. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9618. * 2 means half of the size.
  9619. */
  9620. blurScale: number;
  9621. private _blurKernel;
  9622. /**
  9623. * Gets the blur kernel: kernel size of the blur pass.
  9624. * Only useful if useKernelBlur = true
  9625. */
  9626. /**
  9627. * Sets the blur kernel: kernel size of the blur pass.
  9628. * Only useful if useKernelBlur = true
  9629. */
  9630. blurKernel: number;
  9631. private _useKernelBlur;
  9632. /**
  9633. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9634. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9635. */
  9636. /**
  9637. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9638. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9639. */
  9640. useKernelBlur: boolean;
  9641. private _depthScale;
  9642. /**
  9643. * Gets the depth scale used in ESM mode.
  9644. */
  9645. /**
  9646. * Sets the depth scale used in ESM mode.
  9647. * This can override the scale stored on the light.
  9648. */
  9649. depthScale: number;
  9650. private _filter;
  9651. /**
  9652. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9653. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9654. */
  9655. /**
  9656. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9657. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9658. */
  9659. filter: number;
  9660. /**
  9661. * Gets if the current filter is set to Poisson Sampling.
  9662. */
  9663. /**
  9664. * Sets the current filter to Poisson Sampling.
  9665. */
  9666. usePoissonSampling: boolean;
  9667. /**
  9668. * Gets if the current filter is set to ESM.
  9669. */
  9670. /**
  9671. * Sets the current filter is to ESM.
  9672. */
  9673. useExponentialShadowMap: boolean;
  9674. /**
  9675. * Gets if the current filter is set to filtered ESM.
  9676. */
  9677. /**
  9678. * Gets if the current filter is set to filtered ESM.
  9679. */
  9680. useBlurExponentialShadowMap: boolean;
  9681. /**
  9682. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9683. * exponential to prevent steep falloff artifacts).
  9684. */
  9685. /**
  9686. * Sets the current filter to "close ESM" (using the inverse of the
  9687. * exponential to prevent steep falloff artifacts).
  9688. */
  9689. useCloseExponentialShadowMap: boolean;
  9690. /**
  9691. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9692. * exponential to prevent steep falloff artifacts).
  9693. */
  9694. /**
  9695. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9696. * exponential to prevent steep falloff artifacts).
  9697. */
  9698. useBlurCloseExponentialShadowMap: boolean;
  9699. /**
  9700. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9701. */
  9702. /**
  9703. * Sets the current filter to "PCF" (percentage closer filtering).
  9704. */
  9705. usePercentageCloserFiltering: boolean;
  9706. private _filteringQuality;
  9707. /**
  9708. * Gets the PCF or PCSS Quality.
  9709. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9710. */
  9711. /**
  9712. * Sets the PCF or PCSS Quality.
  9713. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9714. */
  9715. filteringQuality: number;
  9716. /**
  9717. * Gets if the current filter is set to "PCSS" (contact hardening).
  9718. */
  9719. /**
  9720. * Sets the current filter to "PCSS" (contact hardening).
  9721. */
  9722. useContactHardeningShadow: boolean;
  9723. private _contactHardeningLightSizeUVRatio;
  9724. /**
  9725. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9726. * Using a ratio helps keeping shape stability independently of the map size.
  9727. *
  9728. * It does not account for the light projection as it was having too much
  9729. * instability during the light setup or during light position changes.
  9730. *
  9731. * Only valid if useContactHardeningShadow is true.
  9732. */
  9733. /**
  9734. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9735. * Using a ratio helps keeping shape stability independently of the map size.
  9736. *
  9737. * It does not account for the light projection as it was having too much
  9738. * instability during the light setup or during light position changes.
  9739. *
  9740. * Only valid if useContactHardeningShadow is true.
  9741. */
  9742. contactHardeningLightSizeUVRatio: number;
  9743. private _darkness;
  9744. /**
  9745. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9746. * 0 means strongest and 1 would means no shadow.
  9747. * @returns the darkness.
  9748. */
  9749. getDarkness(): number;
  9750. /**
  9751. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9752. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9753. * @returns the shadow generator allowing fluent coding.
  9754. */
  9755. setDarkness(darkness: number): ShadowGenerator;
  9756. private _transparencyShadow;
  9757. /**
  9758. * Sets the ability to have transparent shadow (boolean).
  9759. * @param transparent True if transparent else False
  9760. * @returns the shadow generator allowing fluent coding
  9761. */
  9762. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9763. private _shadowMap;
  9764. private _shadowMap2;
  9765. /**
  9766. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9767. * @returns The render target texture if present otherwise, null
  9768. */
  9769. getShadowMap(): Nullable<RenderTargetTexture>;
  9770. /**
  9771. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9772. * @returns The render target texture if the shadow map is present otherwise, null
  9773. */
  9774. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9775. /**
  9776. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9777. * @param mesh Mesh to add
  9778. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9779. * @returns the Shadow Generator itself
  9780. */
  9781. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9782. /**
  9783. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9784. * @param mesh Mesh to remove
  9785. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9786. * @returns the Shadow Generator itself
  9787. */
  9788. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9789. /**
  9790. * Controls the extent to which the shadows fade out at the edge of the frustum
  9791. * Used only by directionals and spots
  9792. */
  9793. frustumEdgeFalloff: number;
  9794. private _light;
  9795. /**
  9796. * Returns the associated light object.
  9797. * @returns the light generating the shadow
  9798. */
  9799. getLight(): IShadowLight;
  9800. /**
  9801. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9802. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9803. * It might on the other hand introduce peter panning.
  9804. */
  9805. forceBackFacesOnly: boolean;
  9806. private _scene;
  9807. private _lightDirection;
  9808. private _effect;
  9809. private _viewMatrix;
  9810. private _projectionMatrix;
  9811. private _transformMatrix;
  9812. private _cachedPosition;
  9813. private _cachedDirection;
  9814. private _cachedDefines;
  9815. private _currentRenderID;
  9816. private _boxBlurPostprocess;
  9817. private _kernelBlurXPostprocess;
  9818. private _kernelBlurYPostprocess;
  9819. private _blurPostProcesses;
  9820. private _mapSize;
  9821. private _currentFaceIndex;
  9822. private _currentFaceIndexCache;
  9823. private _textureType;
  9824. private _defaultTextureMatrix;
  9825. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  9826. /**
  9827. * Creates a ShadowGenerator object.
  9828. * A ShadowGenerator is the required tool to use the shadows.
  9829. * Each light casting shadows needs to use its own ShadowGenerator.
  9830. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9831. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9832. * @param light The light object generating the shadows.
  9833. * @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.
  9834. */
  9835. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9836. private _initializeGenerator;
  9837. private _initializeShadowMap;
  9838. private _initializeBlurRTTAndPostProcesses;
  9839. private _renderForShadowMap;
  9840. private _renderSubMeshForShadowMap;
  9841. private _applyFilterValues;
  9842. /**
  9843. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9844. * @param onCompiled Callback triggered at the and of the effects compilation
  9845. * @param options Sets of optional options forcing the compilation with different modes
  9846. */
  9847. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9848. useInstances: boolean;
  9849. }>): void;
  9850. /**
  9851. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9852. * @param options Sets of optional options forcing the compilation with different modes
  9853. * @returns A promise that resolves when the compilation completes
  9854. */
  9855. forceCompilationAsync(options?: Partial<{
  9856. useInstances: boolean;
  9857. }>): Promise<void>;
  9858. /**
  9859. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9860. * @param subMesh The submesh we want to render in the shadow map
  9861. * @param useInstances Defines wether will draw in the map using instances
  9862. * @returns true if ready otherwise, false
  9863. */
  9864. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9865. /**
  9866. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9867. * @param defines Defines of the material we want to update
  9868. * @param lightIndex Index of the light in the enabled light list of the material
  9869. */
  9870. prepareDefines(defines: any, lightIndex: number): void;
  9871. /**
  9872. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9873. * defined in the generator but impacting the effect).
  9874. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9875. * @param effect The effect we are binfing the information for
  9876. */
  9877. bindShadowLight(lightIndex: string, effect: Effect): void;
  9878. /**
  9879. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9880. * (eq to shadow prjection matrix * light transform matrix)
  9881. * @returns The transform matrix used to create the shadow map
  9882. */
  9883. getTransformMatrix(): Matrix;
  9884. /**
  9885. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9886. * Cube and 2D textures for instance.
  9887. */
  9888. recreateShadowMap(): void;
  9889. private _disposeBlurPostProcesses;
  9890. private _disposeRTTandPostProcesses;
  9891. /**
  9892. * Disposes the ShadowGenerator.
  9893. * Returns nothing.
  9894. */
  9895. dispose(): void;
  9896. /**
  9897. * Serializes the shadow generator setup to a json object.
  9898. * @returns The serialized JSON object
  9899. */
  9900. serialize(): any;
  9901. /**
  9902. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9903. * @param parsedShadowGenerator The JSON object to parse
  9904. * @param scene The scene to create the shadow map for
  9905. * @returns The parsed shadow generator
  9906. */
  9907. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9908. }
  9909. }
  9910. declare module BABYLON {
  9911. /**
  9912. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9913. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9914. * 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.
  9915. */
  9916. export abstract class Light extends Node {
  9917. /**
  9918. * Falloff Default: light is falling off following the material specification:
  9919. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9920. */
  9921. static readonly FALLOFF_DEFAULT: number;
  9922. /**
  9923. * Falloff Physical: light is falling off following the inverse squared distance law.
  9924. */
  9925. static readonly FALLOFF_PHYSICAL: number;
  9926. /**
  9927. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9928. * to enhance interoperability with other engines.
  9929. */
  9930. static readonly FALLOFF_GLTF: number;
  9931. /**
  9932. * Falloff Standard: light is falling off like in the standard material
  9933. * to enhance interoperability with other materials.
  9934. */
  9935. static readonly FALLOFF_STANDARD: number;
  9936. /**
  9937. * If every light affecting the material is in this lightmapMode,
  9938. * material.lightmapTexture adds or multiplies
  9939. * (depends on material.useLightmapAsShadowmap)
  9940. * after every other light calculations.
  9941. */
  9942. static readonly LIGHTMAP_DEFAULT: number;
  9943. /**
  9944. * material.lightmapTexture as only diffuse lighting from this light
  9945. * adds only specular lighting from this light
  9946. * adds dynamic shadows
  9947. */
  9948. static readonly LIGHTMAP_SPECULAR: number;
  9949. /**
  9950. * material.lightmapTexture as only lighting
  9951. * no light calculation from this light
  9952. * only adds dynamic shadows from this light
  9953. */
  9954. static readonly LIGHTMAP_SHADOWSONLY: number;
  9955. /**
  9956. * Each light type uses the default quantity according to its type:
  9957. * point/spot lights use luminous intensity
  9958. * directional lights use illuminance
  9959. */
  9960. static readonly INTENSITYMODE_AUTOMATIC: number;
  9961. /**
  9962. * lumen (lm)
  9963. */
  9964. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9965. /**
  9966. * candela (lm/sr)
  9967. */
  9968. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9969. /**
  9970. * lux (lm/m^2)
  9971. */
  9972. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9973. /**
  9974. * nit (cd/m^2)
  9975. */
  9976. static readonly INTENSITYMODE_LUMINANCE: number;
  9977. /**
  9978. * Light type const id of the point light.
  9979. */
  9980. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9981. /**
  9982. * Light type const id of the directional light.
  9983. */
  9984. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9985. /**
  9986. * Light type const id of the spot light.
  9987. */
  9988. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9989. /**
  9990. * Light type const id of the hemispheric light.
  9991. */
  9992. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9993. /**
  9994. * Diffuse gives the basic color to an object.
  9995. */
  9996. diffuse: Color3;
  9997. /**
  9998. * Specular produces a highlight color on an object.
  9999. * Note: This is note affecting PBR materials.
  10000. */
  10001. specular: Color3;
  10002. /**
  10003. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10004. * falling off base on range or angle.
  10005. * This can be set to any values in Light.FALLOFF_x.
  10006. *
  10007. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10008. * other types of materials.
  10009. */
  10010. falloffType: number;
  10011. /**
  10012. * Strength of the light.
  10013. * Note: By default it is define in the framework own unit.
  10014. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10015. */
  10016. intensity: number;
  10017. private _range;
  10018. protected _inverseSquaredRange: number;
  10019. /**
  10020. * Defines how far from the source the light is impacting in scene units.
  10021. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10022. */
  10023. /**
  10024. * Defines how far from the source the light is impacting in scene units.
  10025. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10026. */
  10027. range: number;
  10028. /**
  10029. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10030. * of light.
  10031. */
  10032. private _photometricScale;
  10033. private _intensityMode;
  10034. /**
  10035. * Gets the photometric scale used to interpret the intensity.
  10036. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10037. */
  10038. /**
  10039. * Sets the photometric scale used to interpret the intensity.
  10040. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10041. */
  10042. intensityMode: number;
  10043. private _radius;
  10044. /**
  10045. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10046. */
  10047. /**
  10048. * sets the light radius used by PBR Materials to simulate soft area lights.
  10049. */
  10050. radius: number;
  10051. private _renderPriority;
  10052. /**
  10053. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10054. * exceeding the number allowed of the materials.
  10055. */
  10056. renderPriority: number;
  10057. private _shadowEnabled;
  10058. /**
  10059. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10060. * the current shadow generator.
  10061. */
  10062. /**
  10063. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10064. * the current shadow generator.
  10065. */
  10066. shadowEnabled: boolean;
  10067. private _includedOnlyMeshes;
  10068. /**
  10069. * Gets the only meshes impacted by this light.
  10070. */
  10071. /**
  10072. * Sets the only meshes impacted by this light.
  10073. */
  10074. includedOnlyMeshes: AbstractMesh[];
  10075. private _excludedMeshes;
  10076. /**
  10077. * Gets the meshes not impacted by this light.
  10078. */
  10079. /**
  10080. * Sets the meshes not impacted by this light.
  10081. */
  10082. excludedMeshes: AbstractMesh[];
  10083. private _excludeWithLayerMask;
  10084. /**
  10085. * Gets the layer id use to find what meshes are not impacted by the light.
  10086. * Inactive if 0
  10087. */
  10088. /**
  10089. * Sets the layer id use to find what meshes are not impacted by the light.
  10090. * Inactive if 0
  10091. */
  10092. excludeWithLayerMask: number;
  10093. private _includeOnlyWithLayerMask;
  10094. /**
  10095. * Gets the layer id use to find what meshes are impacted by the light.
  10096. * Inactive if 0
  10097. */
  10098. /**
  10099. * Sets the layer id use to find what meshes are impacted by the light.
  10100. * Inactive if 0
  10101. */
  10102. includeOnlyWithLayerMask: number;
  10103. private _lightmapMode;
  10104. /**
  10105. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10106. */
  10107. /**
  10108. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10109. */
  10110. lightmapMode: number;
  10111. /**
  10112. * Shadow generator associted to the light.
  10113. * @hidden Internal use only.
  10114. */ shadowGenerator: Nullable<IShadowGenerator>;
  10115. /**
  10116. * @hidden Internal use only.
  10117. */ excludedMeshesIds: string[];
  10118. /**
  10119. * @hidden Internal use only.
  10120. */ includedOnlyMeshesIds: string[];
  10121. /**
  10122. * The current light unifom buffer.
  10123. * @hidden Internal use only.
  10124. */ uniformBuffer: UniformBuffer;
  10125. /**
  10126. * Creates a Light object in the scene.
  10127. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10128. * @param name The firendly name of the light
  10129. * @param scene The scene the light belongs too
  10130. */
  10131. constructor(name: string, scene: Scene);
  10132. protected abstract _buildUniformLayout(): void;
  10133. /**
  10134. * Sets the passed Effect "effect" with the Light information.
  10135. * @param effect The effect to update
  10136. * @param lightIndex The index of the light in the effect to update
  10137. * @returns The light
  10138. */
  10139. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10140. /**
  10141. * Returns the string "Light".
  10142. * @returns the class name
  10143. */
  10144. getClassName(): string;
  10145. /** @hidden */ protected readonly _isLight: boolean;
  10146. /**
  10147. * Converts the light information to a readable string for debug purpose.
  10148. * @param fullDetails Supports for multiple levels of logging within scene loading
  10149. * @returns the human readable light info
  10150. */
  10151. toString(fullDetails?: boolean): string;
  10152. /** @hidden */
  10153. protected _syncParentEnabledState(): void;
  10154. /**
  10155. * Set the enabled state of this node.
  10156. * @param value - the new enabled state
  10157. */
  10158. setEnabled(value: boolean): void;
  10159. /**
  10160. * Returns the Light associated shadow generator if any.
  10161. * @return the associated shadow generator.
  10162. */
  10163. getShadowGenerator(): Nullable<IShadowGenerator>;
  10164. /**
  10165. * Returns a Vector3, the absolute light position in the World.
  10166. * @returns the world space position of the light
  10167. */
  10168. getAbsolutePosition(): Vector3;
  10169. /**
  10170. * Specifies if the light will affect the passed mesh.
  10171. * @param mesh The mesh to test against the light
  10172. * @return true the mesh is affected otherwise, false.
  10173. */
  10174. canAffectMesh(mesh: AbstractMesh): boolean;
  10175. /**
  10176. * Sort function to order lights for rendering.
  10177. * @param a First Light object to compare to second.
  10178. * @param b Second Light object to compare first.
  10179. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10180. */
  10181. static CompareLightsPriority(a: Light, b: Light): number;
  10182. /**
  10183. * Releases resources associated with this node.
  10184. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10185. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10186. */
  10187. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10188. /**
  10189. * Returns the light type ID (integer).
  10190. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10191. */
  10192. getTypeID(): number;
  10193. /**
  10194. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10195. * @returns the scaled intensity in intensity mode unit
  10196. */
  10197. getScaledIntensity(): number;
  10198. /**
  10199. * Returns a new Light object, named "name", from the current one.
  10200. * @param name The name of the cloned light
  10201. * @returns the new created light
  10202. */
  10203. clone(name: string): Nullable<Light>;
  10204. /**
  10205. * Serializes the current light into a Serialization object.
  10206. * @returns the serialized object.
  10207. */
  10208. serialize(): any;
  10209. /**
  10210. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10211. * This new light is named "name" and added to the passed scene.
  10212. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10213. * @param name The friendly name of the light
  10214. * @param scene The scene the new light will belong to
  10215. * @returns the constructor function
  10216. */
  10217. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10218. /**
  10219. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10220. * @param parsedLight The JSON representation of the light
  10221. * @param scene The scene to create the parsed light in
  10222. * @returns the created light after parsing
  10223. */
  10224. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10225. private _hookArrayForExcluded;
  10226. private _hookArrayForIncludedOnly;
  10227. private _resyncMeshes;
  10228. /**
  10229. * Forces the meshes to update their light related information in their rendering used effects
  10230. * @hidden Internal Use Only
  10231. */ markMeshesAsLightDirty(): void;
  10232. /**
  10233. * Recomputes the cached photometric scale if needed.
  10234. */
  10235. private _computePhotometricScale;
  10236. /**
  10237. * Returns the Photometric Scale according to the light type and intensity mode.
  10238. */
  10239. private _getPhotometricScale;
  10240. /**
  10241. * Reorder the light in the scene according to their defined priority.
  10242. * @hidden Internal Use Only
  10243. */ reorderLightsInScene(): void;
  10244. /**
  10245. * Prepares the list of defines specific to the light type.
  10246. * @param defines the list of defines
  10247. * @param lightIndex defines the index of the light for the effect
  10248. */
  10249. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10250. }
  10251. }
  10252. declare module BABYLON {
  10253. /**
  10254. * Interface used to define Action
  10255. */
  10256. export interface IAction {
  10257. /**
  10258. * Trigger for the action
  10259. */
  10260. trigger: number;
  10261. /** Options of the trigger */
  10262. triggerOptions: any;
  10263. /**
  10264. * Gets the trigger parameters
  10265. * @returns the trigger parameters
  10266. */
  10267. getTriggerParameter(): any;
  10268. /**
  10269. * Internal only - executes current action event
  10270. * @hidden
  10271. */ executeCurrent(evt?: ActionEvent): void;
  10272. /**
  10273. * Serialize placeholder for child classes
  10274. * @param parent of child
  10275. * @returns the serialized object
  10276. */
  10277. serialize(parent: any): any;
  10278. /**
  10279. * Internal only
  10280. * @hidden
  10281. */ prepare(): void;
  10282. /**
  10283. * Internal only - manager for action
  10284. * @hidden
  10285. */ actionManager: AbstractActionManager;
  10286. }
  10287. /**
  10288. * The action to be carried out following a trigger
  10289. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10290. */
  10291. export class Action implements IAction {
  10292. /** the trigger, with or without parameters, for the action */
  10293. triggerOptions: any;
  10294. /**
  10295. * Trigger for the action
  10296. */
  10297. trigger: number;
  10298. /**
  10299. * Internal only - manager for action
  10300. * @hidden
  10301. */ actionManager: ActionManager;
  10302. private _nextActiveAction;
  10303. private _child;
  10304. private _condition?;
  10305. private _triggerParameter;
  10306. /**
  10307. * An event triggered prior to action being executed.
  10308. */
  10309. onBeforeExecuteObservable: Observable<Action>;
  10310. /**
  10311. * Creates a new Action
  10312. * @param triggerOptions the trigger, with or without parameters, for the action
  10313. * @param condition an optional determinant of action
  10314. */
  10315. constructor(
  10316. /** the trigger, with or without parameters, for the action */
  10317. triggerOptions: any, condition?: Condition);
  10318. /**
  10319. * Internal only
  10320. * @hidden
  10321. */ prepare(): void;
  10322. /**
  10323. * Gets the trigger parameters
  10324. * @returns the trigger parameters
  10325. */
  10326. getTriggerParameter(): any;
  10327. /**
  10328. * Internal only - executes current action event
  10329. * @hidden
  10330. */ executeCurrent(evt?: ActionEvent): void;
  10331. /**
  10332. * Execute placeholder for child classes
  10333. * @param evt optional action event
  10334. */
  10335. execute(evt?: ActionEvent): void;
  10336. /**
  10337. * Skips to next active action
  10338. */
  10339. skipToNextActiveAction(): void;
  10340. /**
  10341. * Adds action to chain of actions, may be a DoNothingAction
  10342. * @param action defines the next action to execute
  10343. * @returns The action passed in
  10344. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10345. */
  10346. then(action: Action): Action;
  10347. /**
  10348. * Internal only
  10349. * @hidden
  10350. */ getProperty(propertyPath: string): string;
  10351. /**
  10352. * Internal only
  10353. * @hidden
  10354. */ getEffectiveTarget(target: any, propertyPath: string): any;
  10355. /**
  10356. * Serialize placeholder for child classes
  10357. * @param parent of child
  10358. * @returns the serialized object
  10359. */
  10360. serialize(parent: any): any;
  10361. /**
  10362. * Internal only called by serialize
  10363. * @hidden
  10364. */
  10365. protected _serialize(serializedAction: any, parent?: any): any;
  10366. /**
  10367. * Internal only
  10368. * @hidden
  10369. */ private static _SerializeValueAsString: (value: any) => string;
  10370. /**
  10371. * Internal only
  10372. * @hidden
  10373. */ private static _GetTargetProperty: (target: Scene | Node) => {
  10374. name: string;
  10375. targetType: string;
  10376. value: string;
  10377. };
  10378. }
  10379. }
  10380. declare module BABYLON {
  10381. /**
  10382. * A Condition applied to an Action
  10383. */
  10384. export class Condition {
  10385. /**
  10386. * Internal only - manager for action
  10387. * @hidden
  10388. */ actionManager: ActionManager;
  10389. /**
  10390. * Internal only
  10391. * @hidden
  10392. */ evaluationId: number;
  10393. /**
  10394. * Internal only
  10395. * @hidden
  10396. */ currentResult: boolean;
  10397. /**
  10398. * Creates a new Condition
  10399. * @param actionManager the manager of the action the condition is applied to
  10400. */
  10401. constructor(actionManager: ActionManager);
  10402. /**
  10403. * Check if the current condition is valid
  10404. * @returns a boolean
  10405. */
  10406. isValid(): boolean;
  10407. /**
  10408. * Internal only
  10409. * @hidden
  10410. */ getProperty(propertyPath: string): string;
  10411. /**
  10412. * Internal only
  10413. * @hidden
  10414. */ getEffectiveTarget(target: any, propertyPath: string): any;
  10415. /**
  10416. * Serialize placeholder for child classes
  10417. * @returns the serialized object
  10418. */
  10419. serialize(): any;
  10420. /**
  10421. * Internal only
  10422. * @hidden
  10423. */
  10424. protected _serialize(serializedCondition: any): any;
  10425. }
  10426. /**
  10427. * Defines specific conditional operators as extensions of Condition
  10428. */
  10429. export class ValueCondition extends Condition {
  10430. /** path to specify the property of the target the conditional operator uses */
  10431. propertyPath: string;
  10432. /** the value compared by the conditional operator against the current value of the property */
  10433. value: any;
  10434. /** the conditional operator, default ValueCondition.IsEqual */
  10435. operator: number;
  10436. /**
  10437. * Internal only
  10438. * @hidden
  10439. */
  10440. private static _IsEqual;
  10441. /**
  10442. * Internal only
  10443. * @hidden
  10444. */
  10445. private static _IsDifferent;
  10446. /**
  10447. * Internal only
  10448. * @hidden
  10449. */
  10450. private static _IsGreater;
  10451. /**
  10452. * Internal only
  10453. * @hidden
  10454. */
  10455. private static _IsLesser;
  10456. /**
  10457. * returns the number for IsEqual
  10458. */
  10459. static readonly IsEqual: number;
  10460. /**
  10461. * Returns the number for IsDifferent
  10462. */
  10463. static readonly IsDifferent: number;
  10464. /**
  10465. * Returns the number for IsGreater
  10466. */
  10467. static readonly IsGreater: number;
  10468. /**
  10469. * Returns the number for IsLesser
  10470. */
  10471. static readonly IsLesser: number;
  10472. /**
  10473. * Internal only The action manager for the condition
  10474. * @hidden
  10475. */ actionManager: ActionManager;
  10476. /**
  10477. * Internal only
  10478. * @hidden
  10479. */
  10480. private _target;
  10481. /**
  10482. * Internal only
  10483. * @hidden
  10484. */
  10485. private _effectiveTarget;
  10486. /**
  10487. * Internal only
  10488. * @hidden
  10489. */
  10490. private _property;
  10491. /**
  10492. * Creates a new ValueCondition
  10493. * @param actionManager manager for the action the condition applies to
  10494. * @param target for the action
  10495. * @param propertyPath path to specify the property of the target the conditional operator uses
  10496. * @param value the value compared by the conditional operator against the current value of the property
  10497. * @param operator the conditional operator, default ValueCondition.IsEqual
  10498. */
  10499. constructor(actionManager: ActionManager, target: any,
  10500. /** path to specify the property of the target the conditional operator uses */
  10501. propertyPath: string,
  10502. /** the value compared by the conditional operator against the current value of the property */
  10503. value: any,
  10504. /** the conditional operator, default ValueCondition.IsEqual */
  10505. operator?: number);
  10506. /**
  10507. * Compares the given value with the property value for the specified conditional operator
  10508. * @returns the result of the comparison
  10509. */
  10510. isValid(): boolean;
  10511. /**
  10512. * Serialize the ValueCondition into a JSON compatible object
  10513. * @returns serialization object
  10514. */
  10515. serialize(): any;
  10516. /**
  10517. * Gets the name of the conditional operator for the ValueCondition
  10518. * @param operator the conditional operator
  10519. * @returns the name
  10520. */
  10521. static GetOperatorName(operator: number): string;
  10522. }
  10523. /**
  10524. * Defines a predicate condition as an extension of Condition
  10525. */
  10526. export class PredicateCondition extends Condition {
  10527. /** defines the predicate function used to validate the condition */
  10528. predicate: () => boolean;
  10529. /**
  10530. * Internal only - manager for action
  10531. * @hidden
  10532. */ actionManager: ActionManager;
  10533. /**
  10534. * Creates a new PredicateCondition
  10535. * @param actionManager manager for the action the condition applies to
  10536. * @param predicate defines the predicate function used to validate the condition
  10537. */
  10538. constructor(actionManager: ActionManager,
  10539. /** defines the predicate function used to validate the condition */
  10540. predicate: () => boolean);
  10541. /**
  10542. * @returns the validity of the predicate condition
  10543. */
  10544. isValid(): boolean;
  10545. }
  10546. /**
  10547. * Defines a state condition as an extension of Condition
  10548. */
  10549. export class StateCondition extends Condition {
  10550. /** Value to compare with target state */
  10551. value: string;
  10552. /**
  10553. * Internal only - manager for action
  10554. * @hidden
  10555. */ actionManager: ActionManager;
  10556. /**
  10557. * Internal only
  10558. * @hidden
  10559. */
  10560. private _target;
  10561. /**
  10562. * Creates a new StateCondition
  10563. * @param actionManager manager for the action the condition applies to
  10564. * @param target of the condition
  10565. * @param value to compare with target state
  10566. */
  10567. constructor(actionManager: ActionManager, target: any,
  10568. /** Value to compare with target state */
  10569. value: string);
  10570. /**
  10571. * Gets a boolean indicating if the current condition is met
  10572. * @returns the validity of the state
  10573. */
  10574. isValid(): boolean;
  10575. /**
  10576. * Serialize the StateCondition into a JSON compatible object
  10577. * @returns serialization object
  10578. */
  10579. serialize(): any;
  10580. }
  10581. }
  10582. declare module BABYLON {
  10583. /**
  10584. * This defines an action responsible to toggle a boolean once triggered.
  10585. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10586. */
  10587. export class SwitchBooleanAction extends Action {
  10588. /**
  10589. * The path to the boolean property in the target object
  10590. */
  10591. propertyPath: string;
  10592. private _target;
  10593. private _effectiveTarget;
  10594. private _property;
  10595. /**
  10596. * Instantiate the action
  10597. * @param triggerOptions defines the trigger options
  10598. * @param target defines the object containing the boolean
  10599. * @param propertyPath defines the path to the boolean property in the target object
  10600. * @param condition defines the trigger related conditions
  10601. */
  10602. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10603. /** @hidden */ prepare(): void;
  10604. /**
  10605. * Execute the action toggle the boolean value.
  10606. */
  10607. execute(): void;
  10608. /**
  10609. * Serializes the actions and its related information.
  10610. * @param parent defines the object to serialize in
  10611. * @returns the serialized object
  10612. */
  10613. serialize(parent: any): any;
  10614. }
  10615. /**
  10616. * This defines an action responsible to set a the state field of the target
  10617. * to a desired value once triggered.
  10618. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10619. */
  10620. export class SetStateAction extends Action {
  10621. /**
  10622. * The value to store in the state field.
  10623. */
  10624. value: string;
  10625. private _target;
  10626. /**
  10627. * Instantiate the action
  10628. * @param triggerOptions defines the trigger options
  10629. * @param target defines the object containing the state property
  10630. * @param value defines the value to store in the state field
  10631. * @param condition defines the trigger related conditions
  10632. */
  10633. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10634. /**
  10635. * Execute the action and store the value on the target state property.
  10636. */
  10637. execute(): void;
  10638. /**
  10639. * Serializes the actions and its related information.
  10640. * @param parent defines the object to serialize in
  10641. * @returns the serialized object
  10642. */
  10643. serialize(parent: any): any;
  10644. }
  10645. /**
  10646. * This defines an action responsible to set a property of the target
  10647. * to a desired value once triggered.
  10648. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10649. */
  10650. export class SetValueAction extends Action {
  10651. /**
  10652. * The path of the property to set in the target.
  10653. */
  10654. propertyPath: string;
  10655. /**
  10656. * The value to set in the property
  10657. */
  10658. value: any;
  10659. private _target;
  10660. private _effectiveTarget;
  10661. private _property;
  10662. /**
  10663. * Instantiate the action
  10664. * @param triggerOptions defines the trigger options
  10665. * @param target defines the object containing the property
  10666. * @param propertyPath defines the path of the property to set in the target
  10667. * @param value defines the value to set in the property
  10668. * @param condition defines the trigger related conditions
  10669. */
  10670. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10671. /** @hidden */ prepare(): void;
  10672. /**
  10673. * Execute the action and set the targetted property to the desired value.
  10674. */
  10675. execute(): void;
  10676. /**
  10677. * Serializes the actions and its related information.
  10678. * @param parent defines the object to serialize in
  10679. * @returns the serialized object
  10680. */
  10681. serialize(parent: any): any;
  10682. }
  10683. /**
  10684. * This defines an action responsible to increment the target value
  10685. * to a desired value once triggered.
  10686. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10687. */
  10688. export class IncrementValueAction extends Action {
  10689. /**
  10690. * The path of the property to increment in the target.
  10691. */
  10692. propertyPath: string;
  10693. /**
  10694. * The value we should increment the property by.
  10695. */
  10696. value: any;
  10697. private _target;
  10698. private _effectiveTarget;
  10699. private _property;
  10700. /**
  10701. * Instantiate the action
  10702. * @param triggerOptions defines the trigger options
  10703. * @param target defines the object containing the property
  10704. * @param propertyPath defines the path of the property to increment in the target
  10705. * @param value defines the value value we should increment the property by
  10706. * @param condition defines the trigger related conditions
  10707. */
  10708. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10709. /** @hidden */ prepare(): void;
  10710. /**
  10711. * Execute the action and increment the target of the value amount.
  10712. */
  10713. execute(): void;
  10714. /**
  10715. * Serializes the actions and its related information.
  10716. * @param parent defines the object to serialize in
  10717. * @returns the serialized object
  10718. */
  10719. serialize(parent: any): any;
  10720. }
  10721. /**
  10722. * This defines an action responsible to start an animation once triggered.
  10723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10724. */
  10725. export class PlayAnimationAction extends Action {
  10726. /**
  10727. * Where the animation should start (animation frame)
  10728. */
  10729. from: number;
  10730. /**
  10731. * Where the animation should stop (animation frame)
  10732. */
  10733. to: number;
  10734. /**
  10735. * Define if the animation should loop or stop after the first play.
  10736. */
  10737. loop?: boolean;
  10738. private _target;
  10739. /**
  10740. * Instantiate the action
  10741. * @param triggerOptions defines the trigger options
  10742. * @param target defines the target animation or animation name
  10743. * @param from defines from where the animation should start (animation frame)
  10744. * @param end defines where the animation should stop (animation frame)
  10745. * @param loop defines if the animation should loop or stop after the first play
  10746. * @param condition defines the trigger related conditions
  10747. */
  10748. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10749. /** @hidden */ prepare(): void;
  10750. /**
  10751. * Execute the action and play the animation.
  10752. */
  10753. execute(): void;
  10754. /**
  10755. * Serializes the actions and its related information.
  10756. * @param parent defines the object to serialize in
  10757. * @returns the serialized object
  10758. */
  10759. serialize(parent: any): any;
  10760. }
  10761. /**
  10762. * This defines an action responsible to stop an animation once triggered.
  10763. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10764. */
  10765. export class StopAnimationAction extends Action {
  10766. private _target;
  10767. /**
  10768. * Instantiate the action
  10769. * @param triggerOptions defines the trigger options
  10770. * @param target defines the target animation or animation name
  10771. * @param condition defines the trigger related conditions
  10772. */
  10773. constructor(triggerOptions: any, target: any, condition?: Condition);
  10774. /** @hidden */ prepare(): void;
  10775. /**
  10776. * Execute the action and stop the animation.
  10777. */
  10778. execute(): void;
  10779. /**
  10780. * Serializes the actions and its related information.
  10781. * @param parent defines the object to serialize in
  10782. * @returns the serialized object
  10783. */
  10784. serialize(parent: any): any;
  10785. }
  10786. /**
  10787. * This defines an action responsible that does nothing once triggered.
  10788. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10789. */
  10790. export class DoNothingAction extends Action {
  10791. /**
  10792. * Instantiate the action
  10793. * @param triggerOptions defines the trigger options
  10794. * @param condition defines the trigger related conditions
  10795. */
  10796. constructor(triggerOptions?: any, condition?: Condition);
  10797. /**
  10798. * Execute the action and do nothing.
  10799. */
  10800. execute(): void;
  10801. /**
  10802. * Serializes the actions and its related information.
  10803. * @param parent defines the object to serialize in
  10804. * @returns the serialized object
  10805. */
  10806. serialize(parent: any): any;
  10807. }
  10808. /**
  10809. * This defines an action responsible to trigger several actions once triggered.
  10810. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10811. */
  10812. export class CombineAction extends Action {
  10813. /**
  10814. * The list of aggregated animations to run.
  10815. */
  10816. children: Action[];
  10817. /**
  10818. * Instantiate the action
  10819. * @param triggerOptions defines the trigger options
  10820. * @param children defines the list of aggregated animations to run
  10821. * @param condition defines the trigger related conditions
  10822. */
  10823. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10824. /** @hidden */ prepare(): void;
  10825. /**
  10826. * Execute the action and executes all the aggregated actions.
  10827. */
  10828. execute(evt: ActionEvent): void;
  10829. /**
  10830. * Serializes the actions and its related information.
  10831. * @param parent defines the object to serialize in
  10832. * @returns the serialized object
  10833. */
  10834. serialize(parent: any): any;
  10835. }
  10836. /**
  10837. * This defines an action responsible to run code (external event) once triggered.
  10838. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10839. */
  10840. export class ExecuteCodeAction extends Action {
  10841. /**
  10842. * The callback function to run.
  10843. */
  10844. func: (evt: ActionEvent) => void;
  10845. /**
  10846. * Instantiate the action
  10847. * @param triggerOptions defines the trigger options
  10848. * @param func defines the callback function to run
  10849. * @param condition defines the trigger related conditions
  10850. */
  10851. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10852. /**
  10853. * Execute the action and run the attached code.
  10854. */
  10855. execute(evt: ActionEvent): void;
  10856. }
  10857. /**
  10858. * This defines an action responsible to set the parent property of the target once triggered.
  10859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10860. */
  10861. export class SetParentAction extends Action {
  10862. private _parent;
  10863. private _target;
  10864. /**
  10865. * Instantiate the action
  10866. * @param triggerOptions defines the trigger options
  10867. * @param target defines the target containing the parent property
  10868. * @param parent defines from where the animation should start (animation frame)
  10869. * @param condition defines the trigger related conditions
  10870. */
  10871. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10872. /** @hidden */ prepare(): void;
  10873. /**
  10874. * Execute the action and set the parent property.
  10875. */
  10876. execute(): void;
  10877. /**
  10878. * Serializes the actions and its related information.
  10879. * @param parent defines the object to serialize in
  10880. * @returns the serialized object
  10881. */
  10882. serialize(parent: any): any;
  10883. }
  10884. }
  10885. declare module BABYLON {
  10886. /**
  10887. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10888. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10889. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10890. */
  10891. export class ActionManager extends AbstractActionManager {
  10892. /**
  10893. * Nothing
  10894. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10895. */
  10896. static readonly NothingTrigger: number;
  10897. /**
  10898. * On pick
  10899. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10900. */
  10901. static readonly OnPickTrigger: number;
  10902. /**
  10903. * On left pick
  10904. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10905. */
  10906. static readonly OnLeftPickTrigger: number;
  10907. /**
  10908. * On right pick
  10909. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10910. */
  10911. static readonly OnRightPickTrigger: number;
  10912. /**
  10913. * On center pick
  10914. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10915. */
  10916. static readonly OnCenterPickTrigger: number;
  10917. /**
  10918. * On pick down
  10919. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10920. */
  10921. static readonly OnPickDownTrigger: number;
  10922. /**
  10923. * On double pick
  10924. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10925. */
  10926. static readonly OnDoublePickTrigger: number;
  10927. /**
  10928. * On pick up
  10929. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10930. */
  10931. static readonly OnPickUpTrigger: number;
  10932. /**
  10933. * On pick out.
  10934. * This trigger will only be raised if you also declared a OnPickDown
  10935. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10936. */
  10937. static readonly OnPickOutTrigger: number;
  10938. /**
  10939. * On long press
  10940. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10941. */
  10942. static readonly OnLongPressTrigger: number;
  10943. /**
  10944. * On pointer over
  10945. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10946. */
  10947. static readonly OnPointerOverTrigger: number;
  10948. /**
  10949. * On pointer out
  10950. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10951. */
  10952. static readonly OnPointerOutTrigger: number;
  10953. /**
  10954. * On every frame
  10955. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10956. */
  10957. static readonly OnEveryFrameTrigger: number;
  10958. /**
  10959. * On intersection enter
  10960. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10961. */
  10962. static readonly OnIntersectionEnterTrigger: number;
  10963. /**
  10964. * On intersection exit
  10965. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10966. */
  10967. static readonly OnIntersectionExitTrigger: number;
  10968. /**
  10969. * On key down
  10970. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10971. */
  10972. static readonly OnKeyDownTrigger: number;
  10973. /**
  10974. * On key up
  10975. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10976. */
  10977. static readonly OnKeyUpTrigger: number;
  10978. private _scene;
  10979. /**
  10980. * Creates a new action manager
  10981. * @param scene defines the hosting scene
  10982. */
  10983. constructor(scene: Scene);
  10984. /**
  10985. * Releases all associated resources
  10986. */
  10987. dispose(): void;
  10988. /**
  10989. * Gets hosting scene
  10990. * @returns the hosting scene
  10991. */
  10992. getScene(): Scene;
  10993. /**
  10994. * Does this action manager handles actions of any of the given triggers
  10995. * @param triggers defines the triggers to be tested
  10996. * @return a boolean indicating whether one (or more) of the triggers is handled
  10997. */
  10998. hasSpecificTriggers(triggers: number[]): boolean;
  10999. /**
  11000. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11001. * speed.
  11002. * @param triggerA defines the trigger to be tested
  11003. * @param triggerB defines the trigger to be tested
  11004. * @return a boolean indicating whether one (or more) of the triggers is handled
  11005. */
  11006. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11007. /**
  11008. * Does this action manager handles actions of a given trigger
  11009. * @param trigger defines the trigger to be tested
  11010. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11011. * @return whether the trigger is handled
  11012. */
  11013. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11014. /**
  11015. * Does this action manager has pointer triggers
  11016. */
  11017. readonly hasPointerTriggers: boolean;
  11018. /**
  11019. * Does this action manager has pick triggers
  11020. */
  11021. readonly hasPickTriggers: boolean;
  11022. /**
  11023. * Registers an action to this action manager
  11024. * @param action defines the action to be registered
  11025. * @return the action amended (prepared) after registration
  11026. */
  11027. registerAction(action: IAction): Nullable<IAction>;
  11028. /**
  11029. * Unregisters an action to this action manager
  11030. * @param action defines the action to be unregistered
  11031. * @return a boolean indicating whether the action has been unregistered
  11032. */
  11033. unregisterAction(action: IAction): Boolean;
  11034. /**
  11035. * Process a specific trigger
  11036. * @param trigger defines the trigger to process
  11037. * @param evt defines the event details to be processed
  11038. */
  11039. processTrigger(trigger: number, evt?: IActionEvent): void;
  11040. /** @hidden */ getEffectiveTarget(target: any, propertyPath: string): any;
  11041. /** @hidden */ getProperty(propertyPath: string): string;
  11042. /**
  11043. * Serialize this manager to a JSON object
  11044. * @param name defines the property name to store this manager
  11045. * @returns a JSON representation of this manager
  11046. */
  11047. serialize(name: string): any;
  11048. /**
  11049. * Creates a new ActionManager from a JSON data
  11050. * @param parsedActions defines the JSON data to read from
  11051. * @param object defines the hosting mesh
  11052. * @param scene defines the hosting scene
  11053. */
  11054. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11055. /**
  11056. * Get a trigger name by index
  11057. * @param trigger defines the trigger index
  11058. * @returns a trigger name
  11059. */
  11060. static GetTriggerName(trigger: number): string;
  11061. }
  11062. }
  11063. declare module BABYLON {
  11064. /**
  11065. * Class representing a ray with position and direction
  11066. */
  11067. export class Ray {
  11068. /** origin point */
  11069. origin: Vector3;
  11070. /** direction */
  11071. direction: Vector3;
  11072. /** length of the ray */
  11073. length: number;
  11074. private static readonly TmpVector3;
  11075. private _tmpRay;
  11076. /**
  11077. * Creates a new ray
  11078. * @param origin origin point
  11079. * @param direction direction
  11080. * @param length length of the ray
  11081. */
  11082. constructor(
  11083. /** origin point */
  11084. origin: Vector3,
  11085. /** direction */
  11086. direction: Vector3,
  11087. /** length of the ray */
  11088. length?: number);
  11089. /**
  11090. * Checks if the ray intersects a box
  11091. * @param minimum bound of the box
  11092. * @param maximum bound of the box
  11093. * @param intersectionTreshold extra extend to be added to the box in all direction
  11094. * @returns if the box was hit
  11095. */
  11096. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11097. /**
  11098. * Checks if the ray intersects a box
  11099. * @param box the bounding box to check
  11100. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11101. * @returns if the box was hit
  11102. */
  11103. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11104. /**
  11105. * If the ray hits a sphere
  11106. * @param sphere the bounding sphere to check
  11107. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11108. * @returns true if it hits the sphere
  11109. */
  11110. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11111. /**
  11112. * If the ray hits a triange
  11113. * @param vertex0 triangle vertex
  11114. * @param vertex1 triangle vertex
  11115. * @param vertex2 triangle vertex
  11116. * @returns intersection information if hit
  11117. */
  11118. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11119. /**
  11120. * Checks if ray intersects a plane
  11121. * @param plane the plane to check
  11122. * @returns the distance away it was hit
  11123. */
  11124. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11125. /**
  11126. * Checks if ray intersects a mesh
  11127. * @param mesh the mesh to check
  11128. * @param fastCheck if only the bounding box should checked
  11129. * @returns picking info of the intersecton
  11130. */
  11131. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11132. /**
  11133. * Checks if ray intersects a mesh
  11134. * @param meshes the meshes to check
  11135. * @param fastCheck if only the bounding box should checked
  11136. * @param results array to store result in
  11137. * @returns Array of picking infos
  11138. */
  11139. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11140. private _comparePickingInfo;
  11141. private static smallnum;
  11142. private static rayl;
  11143. /**
  11144. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11145. * @param sega the first point of the segment to test the intersection against
  11146. * @param segb the second point of the segment to test the intersection against
  11147. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11148. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11149. */
  11150. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11151. /**
  11152. * Update the ray from viewport position
  11153. * @param x position
  11154. * @param y y position
  11155. * @param viewportWidth viewport width
  11156. * @param viewportHeight viewport height
  11157. * @param world world matrix
  11158. * @param view view matrix
  11159. * @param projection projection matrix
  11160. * @returns this ray updated
  11161. */
  11162. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11163. /**
  11164. * Creates a ray with origin and direction of 0,0,0
  11165. * @returns the new ray
  11166. */
  11167. static Zero(): Ray;
  11168. /**
  11169. * Creates a new ray from screen space and viewport
  11170. * @param x position
  11171. * @param y y position
  11172. * @param viewportWidth viewport width
  11173. * @param viewportHeight viewport height
  11174. * @param world world matrix
  11175. * @param view view matrix
  11176. * @param projection projection matrix
  11177. * @returns new ray
  11178. */
  11179. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11180. /**
  11181. * 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
  11182. * transformed to the given world matrix.
  11183. * @param origin The origin point
  11184. * @param end The end point
  11185. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11186. * @returns the new ray
  11187. */
  11188. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11189. /**
  11190. * Transforms a ray by a matrix
  11191. * @param ray ray to transform
  11192. * @param matrix matrix to apply
  11193. * @returns the resulting new ray
  11194. */
  11195. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11196. /**
  11197. * Transforms a ray by a matrix
  11198. * @param ray ray to transform
  11199. * @param matrix matrix to apply
  11200. * @param result ray to store result in
  11201. */
  11202. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11203. /**
  11204. * Unproject a ray from screen space to object space
  11205. * @param sourceX defines the screen space x coordinate to use
  11206. * @param sourceY defines the screen space y coordinate to use
  11207. * @param viewportWidth defines the current width of the viewport
  11208. * @param viewportHeight defines the current height of the viewport
  11209. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11210. * @param view defines the view matrix to use
  11211. * @param projection defines the projection matrix to use
  11212. */
  11213. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11214. }
  11215. /**
  11216. * Type used to define predicate used to select faces when a mesh intersection is detected
  11217. */
  11218. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11219. interface Scene {
  11220. /** @hidden */ tempPickingRay: Nullable<Ray>;
  11221. /** @hidden */ cachedRayForTransform: Ray;
  11222. /** @hidden */ pickWithRayInverseMatrix: Matrix;
  11223. /** @hidden */ internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11224. /** @hidden */ internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11225. }
  11226. }
  11227. declare module BABYLON {
  11228. /**
  11229. * Groups all the scene component constants in one place to ease maintenance.
  11230. * @hidden
  11231. */
  11232. export class SceneComponentConstants {
  11233. static readonly NAME_EFFECTLAYER: string;
  11234. static readonly NAME_LAYER: string;
  11235. static readonly NAME_LENSFLARESYSTEM: string;
  11236. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11237. static readonly NAME_PARTICLESYSTEM: string;
  11238. static readonly NAME_GAMEPAD: string;
  11239. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11240. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11241. static readonly NAME_DEPTHRENDERER: string;
  11242. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11243. static readonly NAME_SPRITE: string;
  11244. static readonly NAME_OUTLINERENDERER: string;
  11245. static readonly NAME_PROCEDURALTEXTURE: string;
  11246. static readonly NAME_SHADOWGENERATOR: string;
  11247. static readonly NAME_OCTREE: string;
  11248. static readonly NAME_PHYSICSENGINE: string;
  11249. static readonly NAME_AUDIO: string;
  11250. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11251. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11252. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11253. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11254. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11255. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11256. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11257. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11258. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11259. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11260. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11261. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11262. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11263. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11264. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11265. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11266. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11267. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11268. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11269. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11270. static readonly STEP_AFTERRENDER_AUDIO: number;
  11271. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11272. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11273. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11274. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11275. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11276. static readonly STEP_POINTERMOVE_SPRITE: number;
  11277. static readonly STEP_POINTERDOWN_SPRITE: number;
  11278. static readonly STEP_POINTERUP_SPRITE: number;
  11279. }
  11280. /**
  11281. * This represents a scene component.
  11282. *
  11283. * This is used to decouple the dependency the scene is having on the different workloads like
  11284. * layers, post processes...
  11285. */
  11286. export interface ISceneComponent {
  11287. /**
  11288. * The name of the component. Each component must have a unique name.
  11289. */
  11290. name: string;
  11291. /**
  11292. * The scene the component belongs to.
  11293. */
  11294. scene: Scene;
  11295. /**
  11296. * Register the component to one instance of a scene.
  11297. */
  11298. register(): void;
  11299. /**
  11300. * Rebuilds the elements related to this component in case of
  11301. * context lost for instance.
  11302. */
  11303. rebuild(): void;
  11304. /**
  11305. * Disposes the component and the associated ressources.
  11306. */
  11307. dispose(): void;
  11308. }
  11309. /**
  11310. * This represents a SERIALIZABLE scene component.
  11311. *
  11312. * This extends Scene Component to add Serialization methods on top.
  11313. */
  11314. export interface ISceneSerializableComponent extends ISceneComponent {
  11315. /**
  11316. * Adds all the element from the container to the scene
  11317. * @param container the container holding the elements
  11318. */
  11319. addFromContainer(container: AbstractScene): void;
  11320. /**
  11321. * Removes all the elements in the container from the scene
  11322. * @param container contains the elements to remove
  11323. * @param dispose if the removed element should be disposed (default: false)
  11324. */
  11325. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11326. /**
  11327. * Serializes the component data to the specified json object
  11328. * @param serializationObject The object to serialize to
  11329. */
  11330. serialize(serializationObject: any): void;
  11331. }
  11332. /**
  11333. * Strong typing of a Mesh related stage step action
  11334. */
  11335. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11336. /**
  11337. * Strong typing of a Evaluate Sub Mesh related stage step action
  11338. */
  11339. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11340. /**
  11341. * Strong typing of a Active Mesh related stage step action
  11342. */
  11343. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11344. /**
  11345. * Strong typing of a Camera related stage step action
  11346. */
  11347. export type CameraStageAction = (camera: Camera) => void;
  11348. /**
  11349. * Strong typing of a Render Target related stage step action
  11350. */
  11351. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11352. /**
  11353. * Strong typing of a RenderingGroup related stage step action
  11354. */
  11355. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11356. /**
  11357. * Strong typing of a Mesh Render related stage step action
  11358. */
  11359. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11360. /**
  11361. * Strong typing of a simple stage step action
  11362. */
  11363. export type SimpleStageAction = () => void;
  11364. /**
  11365. * Strong typing of a render target action.
  11366. */
  11367. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11368. /**
  11369. * Strong typing of a pointer move action.
  11370. */
  11371. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11372. /**
  11373. * Strong typing of a pointer up/down action.
  11374. */
  11375. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11376. /**
  11377. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11378. * @hidden
  11379. */
  11380. export class Stage<T extends Function> extends Array<{
  11381. index: number;
  11382. component: ISceneComponent;
  11383. action: T;
  11384. }> {
  11385. /**
  11386. * Hide ctor from the rest of the world.
  11387. * @param items The items to add.
  11388. */
  11389. private constructor();
  11390. /**
  11391. * Creates a new Stage.
  11392. * @returns A new instance of a Stage
  11393. */
  11394. static Create<T extends Function>(): Stage<T>;
  11395. /**
  11396. * Registers a step in an ordered way in the targeted stage.
  11397. * @param index Defines the position to register the step in
  11398. * @param component Defines the component attached to the step
  11399. * @param action Defines the action to launch during the step
  11400. */
  11401. registerStep(index: number, component: ISceneComponent, action: T): void;
  11402. /**
  11403. * Clears all the steps from the stage.
  11404. */
  11405. clear(): void;
  11406. }
  11407. }
  11408. declare module BABYLON {
  11409. interface Scene {
  11410. /** @hidden */ pointerOverSprite: Nullable<Sprite>;
  11411. /** @hidden */ pickedDownSprite: Nullable<Sprite>;
  11412. /** @hidden */ tempSpritePickingRay: Nullable<Ray>;
  11413. /**
  11414. * All of the sprite managers added to this scene
  11415. * @see http://doc.babylonjs.com/babylon101/sprites
  11416. */
  11417. spriteManagers: Array<ISpriteManager>;
  11418. /**
  11419. * An event triggered when sprites rendering is about to start
  11420. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11421. */
  11422. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11423. /**
  11424. * An event triggered when sprites rendering is done
  11425. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11426. */
  11427. onAfterSpritesRenderingObservable: Observable<Scene>;
  11428. /** @hidden */ internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11429. /** Launch a ray to try to pick a sprite in the scene
  11430. * @param x position on screen
  11431. * @param y position on screen
  11432. * @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
  11433. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11434. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11435. * @returns a PickingInfo
  11436. */
  11437. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11438. /** Use the given ray to pick a sprite in the scene
  11439. * @param ray The ray (in world space) to use to pick meshes
  11440. * @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
  11441. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11442. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11443. * @returns a PickingInfo
  11444. */
  11445. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11446. /**
  11447. * Force the sprite under the pointer
  11448. * @param sprite defines the sprite to use
  11449. */
  11450. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11451. /**
  11452. * Gets the sprite under the pointer
  11453. * @returns a Sprite or null if no sprite is under the pointer
  11454. */
  11455. getPointerOverSprite(): Nullable<Sprite>;
  11456. }
  11457. /**
  11458. * Defines the sprite scene component responsible to manage sprites
  11459. * in a given scene.
  11460. */
  11461. export class SpriteSceneComponent implements ISceneComponent {
  11462. /**
  11463. * The component name helpfull to identify the component in the list of scene components.
  11464. */
  11465. readonly name: string;
  11466. /**
  11467. * The scene the component belongs to.
  11468. */
  11469. scene: Scene;
  11470. /** @hidden */
  11471. private _spritePredicate;
  11472. /**
  11473. * Creates a new instance of the component for the given scene
  11474. * @param scene Defines the scene to register the component in
  11475. */
  11476. constructor(scene: Scene);
  11477. /**
  11478. * Registers the component in a given scene
  11479. */
  11480. register(): void;
  11481. /**
  11482. * Rebuilds the elements related to this component in case of
  11483. * context lost for instance.
  11484. */
  11485. rebuild(): void;
  11486. /**
  11487. * Disposes the component and the associated ressources.
  11488. */
  11489. dispose(): void;
  11490. private _pickSpriteButKeepRay;
  11491. private _pointerMove;
  11492. private _pointerDown;
  11493. private _pointerUp;
  11494. }
  11495. }
  11496. declare module BABYLON {
  11497. /** @hidden */
  11498. export var fogFragmentDeclaration: {
  11499. name: string;
  11500. shader: string;
  11501. };
  11502. }
  11503. declare module BABYLON {
  11504. /** @hidden */
  11505. export var fogFragment: {
  11506. name: string;
  11507. shader: string;
  11508. };
  11509. }
  11510. declare module BABYLON {
  11511. /** @hidden */
  11512. export var spritesPixelShader: {
  11513. name: string;
  11514. shader: string;
  11515. };
  11516. }
  11517. declare module BABYLON {
  11518. /** @hidden */
  11519. export var fogVertexDeclaration: {
  11520. name: string;
  11521. shader: string;
  11522. };
  11523. }
  11524. declare module BABYLON {
  11525. /** @hidden */
  11526. export var spritesVertexShader: {
  11527. name: string;
  11528. shader: string;
  11529. };
  11530. }
  11531. declare module BABYLON {
  11532. /**
  11533. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11534. */
  11535. export interface ISpriteManager extends IDisposable {
  11536. /**
  11537. * Restricts the camera to viewing objects with the same layerMask.
  11538. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11539. */
  11540. layerMask: number;
  11541. /**
  11542. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11543. */
  11544. isPickable: boolean;
  11545. /**
  11546. * Specifies the rendering group id for this mesh (0 by default)
  11547. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11548. */
  11549. renderingGroupId: number;
  11550. /**
  11551. * Defines the list of sprites managed by the manager.
  11552. */
  11553. sprites: Array<Sprite>;
  11554. /**
  11555. * Tests the intersection of a sprite with a specific ray.
  11556. * @param ray The ray we are sending to test the collision
  11557. * @param camera The camera space we are sending rays in
  11558. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11559. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11560. * @returns picking info or null.
  11561. */
  11562. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11563. /**
  11564. * Renders the list of sprites on screen.
  11565. */
  11566. render(): void;
  11567. }
  11568. /**
  11569. * Class used to manage multiple sprites on the same spritesheet
  11570. * @see http://doc.babylonjs.com/babylon101/sprites
  11571. */
  11572. export class SpriteManager implements ISpriteManager {
  11573. /** defines the manager's name */
  11574. name: string;
  11575. /** Gets the list of sprites */
  11576. sprites: Sprite[];
  11577. /** Gets or sets the rendering group id (0 by default) */
  11578. renderingGroupId: number;
  11579. /** Gets or sets camera layer mask */
  11580. layerMask: number;
  11581. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11582. fogEnabled: boolean;
  11583. /** Gets or sets a boolean indicating if the sprites are pickable */
  11584. isPickable: boolean;
  11585. /** Defines the default width of a cell in the spritesheet */
  11586. cellWidth: number;
  11587. /** Defines the default height of a cell in the spritesheet */
  11588. cellHeight: number;
  11589. /**
  11590. * An event triggered when the manager is disposed.
  11591. */
  11592. onDisposeObservable: Observable<SpriteManager>;
  11593. private _onDisposeObserver;
  11594. /**
  11595. * Callback called when the manager is disposed
  11596. */
  11597. onDispose: () => void;
  11598. private _capacity;
  11599. private _spriteTexture;
  11600. private _epsilon;
  11601. private _scene;
  11602. private _vertexData;
  11603. private _buffer;
  11604. private _vertexBuffers;
  11605. private _indexBuffer;
  11606. private _effectBase;
  11607. private _effectFog;
  11608. /**
  11609. * Gets or sets the spritesheet texture
  11610. */
  11611. texture: Texture;
  11612. /**
  11613. * Creates a new sprite manager
  11614. * @param name defines the manager's name
  11615. * @param imgUrl defines the sprite sheet url
  11616. * @param capacity defines the maximum allowed number of sprites
  11617. * @param cellSize defines the size of a sprite cell
  11618. * @param scene defines the hosting scene
  11619. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11620. * @param samplingMode defines the smapling mode to use with spritesheet
  11621. */
  11622. constructor(
  11623. /** defines the manager's name */
  11624. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11625. private _appendSpriteVertex;
  11626. /**
  11627. * Intersects the sprites with a ray
  11628. * @param ray defines the ray to intersect with
  11629. * @param camera defines the current active camera
  11630. * @param predicate defines a predicate used to select candidate sprites
  11631. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11632. * @returns null if no hit or a PickingInfo
  11633. */
  11634. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11635. /**
  11636. * Render all child sprites
  11637. */
  11638. render(): void;
  11639. /**
  11640. * Release associated resources
  11641. */
  11642. dispose(): void;
  11643. }
  11644. }
  11645. declare module BABYLON {
  11646. /**
  11647. * Class used to represent a sprite
  11648. * @see http://doc.babylonjs.com/babylon101/sprites
  11649. */
  11650. export class Sprite {
  11651. /** defines the name */
  11652. name: string;
  11653. /** Gets or sets the current world position */
  11654. position: Vector3;
  11655. /** Gets or sets the main color */
  11656. color: Color4;
  11657. /** Gets or sets the width */
  11658. width: number;
  11659. /** Gets or sets the height */
  11660. height: number;
  11661. /** Gets or sets rotation angle */
  11662. angle: number;
  11663. /** Gets or sets the cell index in the sprite sheet */
  11664. cellIndex: number;
  11665. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11666. invertU: number;
  11667. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11668. invertV: number;
  11669. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11670. disposeWhenFinishedAnimating: boolean;
  11671. /** Gets the list of attached animations */
  11672. animations: Animation[];
  11673. /** Gets or sets a boolean indicating if the sprite can be picked */
  11674. isPickable: boolean;
  11675. /**
  11676. * Gets or sets the associated action manager
  11677. */
  11678. actionManager: Nullable<ActionManager>;
  11679. private _animationStarted;
  11680. private _loopAnimation;
  11681. private _fromIndex;
  11682. private _toIndex;
  11683. private _delay;
  11684. private _direction;
  11685. private _manager;
  11686. private _time;
  11687. private _onAnimationEnd;
  11688. /**
  11689. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11690. */
  11691. isVisible: boolean;
  11692. /**
  11693. * Gets or sets the sprite size
  11694. */
  11695. size: number;
  11696. /**
  11697. * Creates a new Sprite
  11698. * @param name defines the name
  11699. * @param manager defines the manager
  11700. */
  11701. constructor(
  11702. /** defines the name */
  11703. name: string, manager: ISpriteManager);
  11704. /**
  11705. * Starts an animation
  11706. * @param from defines the initial key
  11707. * @param to defines the end key
  11708. * @param loop defines if the animation must loop
  11709. * @param delay defines the start delay (in ms)
  11710. * @param onAnimationEnd defines a callback to call when animation ends
  11711. */
  11712. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11713. /** Stops current animation (if any) */
  11714. stopAnimation(): void;
  11715. /** @hidden */ animate(deltaTime: number): void;
  11716. /** Release associated resources */
  11717. dispose(): void;
  11718. }
  11719. }
  11720. declare module BABYLON {
  11721. /**
  11722. * Information about the result of picking within a scene
  11723. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11724. */
  11725. export class PickingInfo {
  11726. /** @hidden */ pickingUnavailable: boolean;
  11727. /**
  11728. * If the pick collided with an object
  11729. */
  11730. hit: boolean;
  11731. /**
  11732. * Distance away where the pick collided
  11733. */
  11734. distance: number;
  11735. /**
  11736. * The location of pick collision
  11737. */
  11738. pickedPoint: Nullable<Vector3>;
  11739. /**
  11740. * The mesh corresponding the the pick collision
  11741. */
  11742. pickedMesh: Nullable<AbstractMesh>;
  11743. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11744. bu: number;
  11745. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11746. bv: number;
  11747. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11748. faceId: number;
  11749. /** Id of the the submesh that was picked */
  11750. subMeshId: number;
  11751. /** If a sprite was picked, this will be the sprite the pick collided with */
  11752. pickedSprite: Nullable<Sprite>;
  11753. /**
  11754. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11755. */
  11756. originMesh: Nullable<AbstractMesh>;
  11757. /**
  11758. * The ray that was used to perform the picking.
  11759. */
  11760. ray: Nullable<Ray>;
  11761. /**
  11762. * Gets the normal correspodning to the face the pick collided with
  11763. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11764. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11765. * @returns The normal correspodning to the face the pick collided with
  11766. */
  11767. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11768. /**
  11769. * Gets the texture coordinates of where the pick occured
  11770. * @returns the vector containing the coordnates of the texture
  11771. */
  11772. getTextureCoordinates(): Nullable<Vector2>;
  11773. }
  11774. }
  11775. declare module BABYLON {
  11776. /**
  11777. * Gather the list of pointer event types as constants.
  11778. */
  11779. export class PointerEventTypes {
  11780. /**
  11781. * 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.
  11782. */
  11783. static readonly POINTERDOWN: number;
  11784. /**
  11785. * The pointerup event is fired when a pointer is no longer active.
  11786. */
  11787. static readonly POINTERUP: number;
  11788. /**
  11789. * The pointermove event is fired when a pointer changes coordinates.
  11790. */
  11791. static readonly POINTERMOVE: number;
  11792. /**
  11793. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11794. */
  11795. static readonly POINTERWHEEL: number;
  11796. /**
  11797. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11798. */
  11799. static readonly POINTERPICK: number;
  11800. /**
  11801. * The pointertap event is fired when a the object has been touched and released without drag.
  11802. */
  11803. static readonly POINTERTAP: number;
  11804. /**
  11805. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11806. */
  11807. static readonly POINTERDOUBLETAP: number;
  11808. }
  11809. /**
  11810. * Base class of pointer info types.
  11811. */
  11812. export class PointerInfoBase {
  11813. /**
  11814. * Defines the type of event (PointerEventTypes)
  11815. */
  11816. type: number;
  11817. /**
  11818. * Defines the related dom event
  11819. */
  11820. event: PointerEvent | MouseWheelEvent;
  11821. /**
  11822. * Instantiates the base class of pointers info.
  11823. * @param type Defines the type of event (PointerEventTypes)
  11824. * @param event Defines the related dom event
  11825. */
  11826. constructor(
  11827. /**
  11828. * Defines the type of event (PointerEventTypes)
  11829. */
  11830. type: number,
  11831. /**
  11832. * Defines the related dom event
  11833. */
  11834. event: PointerEvent | MouseWheelEvent);
  11835. }
  11836. /**
  11837. * This class is used to store pointer related info for the onPrePointerObservable event.
  11838. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11839. */
  11840. export class PointerInfoPre extends PointerInfoBase {
  11841. /**
  11842. * Ray from a pointer if availible (eg. 6dof controller)
  11843. */
  11844. ray: Nullable<Ray>;
  11845. /**
  11846. * Defines the local position of the pointer on the canvas.
  11847. */
  11848. localPosition: Vector2;
  11849. /**
  11850. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11851. */
  11852. skipOnPointerObservable: boolean;
  11853. /**
  11854. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11855. * @param type Defines the type of event (PointerEventTypes)
  11856. * @param event Defines the related dom event
  11857. * @param localX Defines the local x coordinates of the pointer when the event occured
  11858. * @param localY Defines the local y coordinates of the pointer when the event occured
  11859. */
  11860. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11861. }
  11862. /**
  11863. * This type contains all the data related to a pointer event in Babylon.js.
  11864. * 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.
  11865. */
  11866. export class PointerInfo extends PointerInfoBase {
  11867. /**
  11868. * Defines the picking info associated to the info (if any)\
  11869. */
  11870. pickInfo: Nullable<PickingInfo>;
  11871. /**
  11872. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11873. * @param type Defines the type of event (PointerEventTypes)
  11874. * @param event Defines the related dom event
  11875. * @param pickInfo Defines the picking info associated to the info (if any)\
  11876. */
  11877. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11878. /**
  11879. * Defines the picking info associated to the info (if any)\
  11880. */
  11881. pickInfo: Nullable<PickingInfo>);
  11882. }
  11883. /**
  11884. * Data relating to a touch event on the screen.
  11885. */
  11886. export interface PointerTouch {
  11887. /**
  11888. * X coordinate of touch.
  11889. */
  11890. x: number;
  11891. /**
  11892. * Y coordinate of touch.
  11893. */
  11894. y: number;
  11895. /**
  11896. * Id of touch. Unique for each finger.
  11897. */
  11898. pointerId: number;
  11899. /**
  11900. * Event type passed from DOM.
  11901. */
  11902. type: any;
  11903. }
  11904. }
  11905. declare module BABYLON {
  11906. /**
  11907. * Manage the mouse inputs to control the movement of a free camera.
  11908. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11909. */
  11910. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11911. /**
  11912. * Define if touch is enabled in the mouse input
  11913. */
  11914. touchEnabled: boolean;
  11915. /**
  11916. * Defines the camera the input is attached to.
  11917. */
  11918. camera: FreeCamera;
  11919. /**
  11920. * Defines the buttons associated with the input to handle camera move.
  11921. */
  11922. buttons: number[];
  11923. /**
  11924. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11925. */
  11926. angularSensibility: number;
  11927. private _pointerInput;
  11928. private _onMouseMove;
  11929. private _observer;
  11930. private previousPosition;
  11931. /**
  11932. * Observable for when a pointer move event occurs containing the move offset
  11933. */
  11934. onPointerMovedObservable: Observable<{
  11935. offsetX: number;
  11936. offsetY: number;
  11937. }>;
  11938. /**
  11939. * @hidden
  11940. * If the camera should be rotated automatically based on pointer movement
  11941. */ allowCameraRotation: boolean;
  11942. /**
  11943. * Manage the mouse inputs to control the movement of a free camera.
  11944. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11945. * @param touchEnabled Defines if touch is enabled or not
  11946. */
  11947. constructor(
  11948. /**
  11949. * Define if touch is enabled in the mouse input
  11950. */
  11951. touchEnabled?: boolean);
  11952. /**
  11953. * Attach the input controls to a specific dom element to get the input from.
  11954. * @param element Defines the element the controls should be listened from
  11955. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11956. */
  11957. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11958. /**
  11959. * Called on JS contextmenu event.
  11960. * Override this method to provide functionality.
  11961. */
  11962. protected onContextMenu(evt: PointerEvent): void;
  11963. /**
  11964. * Detach the current controls from the specified dom element.
  11965. * @param element Defines the element to stop listening the inputs from
  11966. */
  11967. detachControl(element: Nullable<HTMLElement>): void;
  11968. /**
  11969. * Gets the class name of the current intput.
  11970. * @returns the class name
  11971. */
  11972. getClassName(): string;
  11973. /**
  11974. * Get the friendly name associated with the input class.
  11975. * @returns the input friendly name
  11976. */
  11977. getSimpleName(): string;
  11978. }
  11979. }
  11980. declare module BABYLON {
  11981. /**
  11982. * Manage the touch inputs to control the movement of a free camera.
  11983. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11984. */
  11985. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11986. /**
  11987. * Defines the camera the input is attached to.
  11988. */
  11989. camera: FreeCamera;
  11990. /**
  11991. * Defines the touch sensibility for rotation.
  11992. * The higher the faster.
  11993. */
  11994. touchAngularSensibility: number;
  11995. /**
  11996. * Defines the touch sensibility for move.
  11997. * The higher the faster.
  11998. */
  11999. touchMoveSensibility: number;
  12000. private _offsetX;
  12001. private _offsetY;
  12002. private _pointerPressed;
  12003. private _pointerInput;
  12004. private _observer;
  12005. private _onLostFocus;
  12006. /**
  12007. * Attach the input controls to a specific dom element to get the input from.
  12008. * @param element Defines the element the controls should be listened from
  12009. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12010. */
  12011. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12012. /**
  12013. * Detach the current controls from the specified dom element.
  12014. * @param element Defines the element to stop listening the inputs from
  12015. */
  12016. detachControl(element: Nullable<HTMLElement>): void;
  12017. /**
  12018. * Update the current camera state depending on the inputs that have been used this frame.
  12019. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12020. */
  12021. checkInputs(): void;
  12022. /**
  12023. * Gets the class name of the current intput.
  12024. * @returns the class name
  12025. */
  12026. getClassName(): string;
  12027. /**
  12028. * Get the friendly name associated with the input class.
  12029. * @returns the input friendly name
  12030. */
  12031. getSimpleName(): string;
  12032. }
  12033. }
  12034. declare module BABYLON {
  12035. /**
  12036. * Default Inputs manager for the FreeCamera.
  12037. * It groups all the default supported inputs for ease of use.
  12038. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12039. */
  12040. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12041. /**
  12042. * @hidden
  12043. */ keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  12044. /**
  12045. * @hidden
  12046. */ mouseInput: Nullable<FreeCameraMouseInput>;
  12047. /**
  12048. * Instantiates a new FreeCameraInputsManager.
  12049. * @param camera Defines the camera the inputs belong to
  12050. */
  12051. constructor(camera: FreeCamera);
  12052. /**
  12053. * Add keyboard input support to the input manager.
  12054. * @returns the current input manager
  12055. */
  12056. addKeyboard(): FreeCameraInputsManager;
  12057. /**
  12058. * Add mouse input support to the input manager.
  12059. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12060. * @returns the current input manager
  12061. */
  12062. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12063. /**
  12064. * Removes the mouse input support from the manager
  12065. * @returns the current input manager
  12066. */
  12067. removeMouse(): FreeCameraInputsManager;
  12068. /**
  12069. * Add touch input support to the input manager.
  12070. * @returns the current input manager
  12071. */
  12072. addTouch(): FreeCameraInputsManager;
  12073. }
  12074. }
  12075. declare module BABYLON {
  12076. /**
  12077. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12078. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12079. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12080. */
  12081. export class FreeCamera extends TargetCamera {
  12082. /**
  12083. * Define the collision ellipsoid of the camera.
  12084. * This is helpful to simulate a camera body like the player body around the camera
  12085. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12086. */
  12087. ellipsoid: Vector3;
  12088. /**
  12089. * Define an offset for the position of the ellipsoid around the camera.
  12090. * This can be helpful to determine the center of the body near the gravity center of the body
  12091. * instead of its head.
  12092. */
  12093. ellipsoidOffset: Vector3;
  12094. /**
  12095. * Enable or disable collisions of the camera with the rest of the scene objects.
  12096. */
  12097. checkCollisions: boolean;
  12098. /**
  12099. * Enable or disable gravity on the camera.
  12100. */
  12101. applyGravity: boolean;
  12102. /**
  12103. * Define the input manager associated to the camera.
  12104. */
  12105. inputs: FreeCameraInputsManager;
  12106. /**
  12107. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12108. * Higher values reduce sensitivity.
  12109. */
  12110. /**
  12111. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12112. * Higher values reduce sensitivity.
  12113. */
  12114. angularSensibility: number;
  12115. /**
  12116. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12117. */
  12118. keysUp: number[];
  12119. /**
  12120. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12121. */
  12122. keysDown: number[];
  12123. /**
  12124. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12125. */
  12126. keysLeft: number[];
  12127. /**
  12128. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12129. */
  12130. keysRight: number[];
  12131. /**
  12132. * Event raised when the camera collide with a mesh in the scene.
  12133. */
  12134. onCollide: (collidedMesh: AbstractMesh) => void;
  12135. private _collider;
  12136. private _needMoveForGravity;
  12137. private _oldPosition;
  12138. private _diffPosition;
  12139. private _newPosition;
  12140. /** @hidden */ localDirection: Vector3;
  12141. /** @hidden */ transformedDirection: Vector3;
  12142. /**
  12143. * Instantiates a Free Camera.
  12144. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12145. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12146. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12147. * @param name Define the name of the camera in the scene
  12148. * @param position Define the start position of the camera in the scene
  12149. * @param scene Define the scene the camera belongs to
  12150. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12151. */
  12152. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12153. /**
  12154. * Attached controls to the current camera.
  12155. * @param element Defines the element the controls should be listened from
  12156. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12157. */
  12158. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12159. /**
  12160. * Detach the current controls from the camera.
  12161. * The camera will stop reacting to inputs.
  12162. * @param element Defines the element to stop listening the inputs from
  12163. */
  12164. detachControl(element: HTMLElement): void;
  12165. private _collisionMask;
  12166. /**
  12167. * Define a collision mask to limit the list of object the camera can collide with
  12168. */
  12169. collisionMask: number;
  12170. /** @hidden */ collideWithWorld(displacement: Vector3): void;
  12171. private _onCollisionPositionChange;
  12172. /** @hidden */ checkInputs(): void;
  12173. /** @hidden */ decideIfNeedsToMove(): boolean;
  12174. /** @hidden */ updatePosition(): void;
  12175. /**
  12176. * Destroy the camera and release the current resources hold by it.
  12177. */
  12178. dispose(): void;
  12179. /**
  12180. * Gets the current object class name.
  12181. * @return the class name
  12182. */
  12183. getClassName(): string;
  12184. }
  12185. }
  12186. declare module BABYLON {
  12187. /**
  12188. * Represents a gamepad control stick position
  12189. */
  12190. export class StickValues {
  12191. /**
  12192. * The x component of the control stick
  12193. */
  12194. x: number;
  12195. /**
  12196. * The y component of the control stick
  12197. */
  12198. y: number;
  12199. /**
  12200. * Initializes the gamepad x and y control stick values
  12201. * @param x The x component of the gamepad control stick value
  12202. * @param y The y component of the gamepad control stick value
  12203. */
  12204. constructor(
  12205. /**
  12206. * The x component of the control stick
  12207. */
  12208. x: number,
  12209. /**
  12210. * The y component of the control stick
  12211. */
  12212. y: number);
  12213. }
  12214. /**
  12215. * An interface which manages callbacks for gamepad button changes
  12216. */
  12217. export interface GamepadButtonChanges {
  12218. /**
  12219. * Called when a gamepad has been changed
  12220. */
  12221. changed: boolean;
  12222. /**
  12223. * Called when a gamepad press event has been triggered
  12224. */
  12225. pressChanged: boolean;
  12226. /**
  12227. * Called when a touch event has been triggered
  12228. */
  12229. touchChanged: boolean;
  12230. /**
  12231. * Called when a value has changed
  12232. */
  12233. valueChanged: boolean;
  12234. }
  12235. /**
  12236. * Represents a gamepad
  12237. */
  12238. export class Gamepad {
  12239. /**
  12240. * The id of the gamepad
  12241. */
  12242. id: string;
  12243. /**
  12244. * The index of the gamepad
  12245. */
  12246. index: number;
  12247. /**
  12248. * The browser gamepad
  12249. */
  12250. browserGamepad: any;
  12251. /**
  12252. * Specifies what type of gamepad this represents
  12253. */
  12254. type: number;
  12255. private _leftStick;
  12256. private _rightStick;
  12257. /** @hidden */ isConnected: boolean;
  12258. private _leftStickAxisX;
  12259. private _leftStickAxisY;
  12260. private _rightStickAxisX;
  12261. private _rightStickAxisY;
  12262. /**
  12263. * Triggered when the left control stick has been changed
  12264. */
  12265. private _onleftstickchanged;
  12266. /**
  12267. * Triggered when the right control stick has been changed
  12268. */
  12269. private _onrightstickchanged;
  12270. /**
  12271. * Represents a gamepad controller
  12272. */
  12273. static GAMEPAD: number;
  12274. /**
  12275. * Represents a generic controller
  12276. */
  12277. static GENERIC: number;
  12278. /**
  12279. * Represents an XBox controller
  12280. */
  12281. static XBOX: number;
  12282. /**
  12283. * Represents a pose-enabled controller
  12284. */
  12285. static POSE_ENABLED: number;
  12286. /**
  12287. * Specifies whether the left control stick should be Y-inverted
  12288. */
  12289. protected _invertLeftStickY: boolean;
  12290. /**
  12291. * Specifies if the gamepad has been connected
  12292. */
  12293. readonly isConnected: boolean;
  12294. /**
  12295. * Initializes the gamepad
  12296. * @param id The id of the gamepad
  12297. * @param index The index of the gamepad
  12298. * @param browserGamepad The browser gamepad
  12299. * @param leftStickX The x component of the left joystick
  12300. * @param leftStickY The y component of the left joystick
  12301. * @param rightStickX The x component of the right joystick
  12302. * @param rightStickY The y component of the right joystick
  12303. */
  12304. constructor(
  12305. /**
  12306. * The id of the gamepad
  12307. */
  12308. id: string,
  12309. /**
  12310. * The index of the gamepad
  12311. */
  12312. index: number,
  12313. /**
  12314. * The browser gamepad
  12315. */
  12316. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12317. /**
  12318. * Callback triggered when the left joystick has changed
  12319. * @param callback
  12320. */
  12321. onleftstickchanged(callback: (values: StickValues) => void): void;
  12322. /**
  12323. * Callback triggered when the right joystick has changed
  12324. * @param callback
  12325. */
  12326. onrightstickchanged(callback: (values: StickValues) => void): void;
  12327. /**
  12328. * Gets the left joystick
  12329. */
  12330. /**
  12331. * Sets the left joystick values
  12332. */
  12333. leftStick: StickValues;
  12334. /**
  12335. * Gets the right joystick
  12336. */
  12337. /**
  12338. * Sets the right joystick value
  12339. */
  12340. rightStick: StickValues;
  12341. /**
  12342. * Updates the gamepad joystick positions
  12343. */
  12344. update(): void;
  12345. /**
  12346. * Disposes the gamepad
  12347. */
  12348. dispose(): void;
  12349. }
  12350. /**
  12351. * Represents a generic gamepad
  12352. */
  12353. export class GenericPad extends Gamepad {
  12354. private _buttons;
  12355. private _onbuttondown;
  12356. private _onbuttonup;
  12357. /**
  12358. * Observable triggered when a button has been pressed
  12359. */
  12360. onButtonDownObservable: Observable<number>;
  12361. /**
  12362. * Observable triggered when a button has been released
  12363. */
  12364. onButtonUpObservable: Observable<number>;
  12365. /**
  12366. * Callback triggered when a button has been pressed
  12367. * @param callback Called when a button has been pressed
  12368. */
  12369. onbuttondown(callback: (buttonPressed: number) => void): void;
  12370. /**
  12371. * Callback triggered when a button has been released
  12372. * @param callback Called when a button has been released
  12373. */
  12374. onbuttonup(callback: (buttonReleased: number) => void): void;
  12375. /**
  12376. * Initializes the generic gamepad
  12377. * @param id The id of the generic gamepad
  12378. * @param index The index of the generic gamepad
  12379. * @param browserGamepad The browser gamepad
  12380. */
  12381. constructor(id: string, index: number, browserGamepad: any);
  12382. private _setButtonValue;
  12383. /**
  12384. * Updates the generic gamepad
  12385. */
  12386. update(): void;
  12387. /**
  12388. * Disposes the generic gamepad
  12389. */
  12390. dispose(): void;
  12391. }
  12392. }
  12393. declare module BABYLON {
  12394. /**
  12395. * Defines the types of pose enabled controllers that are supported
  12396. */
  12397. export enum PoseEnabledControllerType {
  12398. /**
  12399. * HTC Vive
  12400. */
  12401. VIVE = 0,
  12402. /**
  12403. * Oculus Rift
  12404. */
  12405. OCULUS = 1,
  12406. /**
  12407. * Windows mixed reality
  12408. */
  12409. WINDOWS = 2,
  12410. /**
  12411. * Samsung gear VR
  12412. */
  12413. GEAR_VR = 3,
  12414. /**
  12415. * Google Daydream
  12416. */
  12417. DAYDREAM = 4,
  12418. /**
  12419. * Generic
  12420. */
  12421. GENERIC = 5
  12422. }
  12423. /**
  12424. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12425. */
  12426. export interface MutableGamepadButton {
  12427. /**
  12428. * Value of the button/trigger
  12429. */
  12430. value: number;
  12431. /**
  12432. * If the button/trigger is currently touched
  12433. */
  12434. touched: boolean;
  12435. /**
  12436. * If the button/trigger is currently pressed
  12437. */
  12438. pressed: boolean;
  12439. }
  12440. /**
  12441. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12442. * @hidden
  12443. */
  12444. export interface ExtendedGamepadButton extends GamepadButton {
  12445. /**
  12446. * If the button/trigger is currently pressed
  12447. */
  12448. readonly pressed: boolean;
  12449. /**
  12450. * If the button/trigger is currently touched
  12451. */
  12452. readonly touched: boolean;
  12453. /**
  12454. * Value of the button/trigger
  12455. */
  12456. readonly value: number;
  12457. }
  12458. /** @hidden */
  12459. export interface _GamePadFactory {
  12460. /**
  12461. * Returns wether or not the current gamepad can be created for this type of controller.
  12462. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12463. * @returns true if it can be created, otherwise false
  12464. */
  12465. canCreate(gamepadInfo: any): boolean;
  12466. /**
  12467. * Creates a new instance of the Gamepad.
  12468. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12469. * @returns the new gamepad instance
  12470. */
  12471. create(gamepadInfo: any): Gamepad;
  12472. }
  12473. /**
  12474. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12475. */
  12476. export class PoseEnabledControllerHelper {
  12477. /** @hidden */ private static _ControllerFactories: _GamePadFactory[];
  12478. /** @hidden */ private static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12479. /**
  12480. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12481. * @param vrGamepad the gamepad to initialized
  12482. * @returns a vr controller of the type the gamepad identified as
  12483. */
  12484. static InitiateController(vrGamepad: any): Gamepad;
  12485. }
  12486. /**
  12487. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12488. */
  12489. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12490. private _deviceRoomPosition;
  12491. private _deviceRoomRotationQuaternion;
  12492. /**
  12493. * The device position in babylon space
  12494. */
  12495. devicePosition: Vector3;
  12496. /**
  12497. * The device rotation in babylon space
  12498. */
  12499. deviceRotationQuaternion: Quaternion;
  12500. /**
  12501. * The scale factor of the device in babylon space
  12502. */
  12503. deviceScaleFactor: number;
  12504. /**
  12505. * (Likely devicePosition should be used instead) The device position in its room space
  12506. */
  12507. position: Vector3;
  12508. /**
  12509. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12510. */
  12511. rotationQuaternion: Quaternion;
  12512. /**
  12513. * The type of controller (Eg. Windows mixed reality)
  12514. */
  12515. controllerType: PoseEnabledControllerType;
  12516. protected _calculatedPosition: Vector3;
  12517. private _calculatedRotation;
  12518. /**
  12519. * The raw pose from the device
  12520. */
  12521. rawPose: DevicePose;
  12522. private _trackPosition;
  12523. private _maxRotationDistFromHeadset;
  12524. private _draggedRoomRotation;
  12525. /**
  12526. * @hidden
  12527. */ disableTrackPosition(fixedPosition: Vector3): void;
  12528. /**
  12529. * Internal, the mesh attached to the controller
  12530. * @hidden
  12531. */ mesh: Nullable<AbstractMesh>;
  12532. private _poseControlledCamera;
  12533. private _leftHandSystemQuaternion;
  12534. /**
  12535. * Internal, matrix used to convert room space to babylon space
  12536. * @hidden
  12537. */ deviceToWorld: Matrix;
  12538. /**
  12539. * Node to be used when casting a ray from the controller
  12540. * @hidden
  12541. */ pointingPoseNode: Nullable<TransformNode>;
  12542. /**
  12543. * Name of the child mesh that can be used to cast a ray from the controller
  12544. */
  12545. static readonly POINTING_POSE: string;
  12546. /**
  12547. * Creates a new PoseEnabledController from a gamepad
  12548. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12549. */
  12550. constructor(browserGamepad: any);
  12551. private _workingMatrix;
  12552. /**
  12553. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12554. */
  12555. update(): void;
  12556. /**
  12557. * Updates only the pose device and mesh without doing any button event checking
  12558. */
  12559. protected _updatePoseAndMesh(): void;
  12560. /**
  12561. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12562. * @param poseData raw pose fromthe device
  12563. */
  12564. updateFromDevice(poseData: DevicePose): void;
  12565. /**
  12566. * @hidden
  12567. */ meshAttachedObservable: Observable<AbstractMesh>;
  12568. /**
  12569. * Attaches a mesh to the controller
  12570. * @param mesh the mesh to be attached
  12571. */
  12572. attachToMesh(mesh: AbstractMesh): void;
  12573. /**
  12574. * Attaches the controllers mesh to a camera
  12575. * @param camera the camera the mesh should be attached to
  12576. */
  12577. attachToPoseControlledCamera(camera: TargetCamera): void;
  12578. /**
  12579. * Disposes of the controller
  12580. */
  12581. dispose(): void;
  12582. /**
  12583. * The mesh that is attached to the controller
  12584. */
  12585. readonly mesh: Nullable<AbstractMesh>;
  12586. /**
  12587. * Gets the ray of the controller in the direction the controller is pointing
  12588. * @param length the length the resulting ray should be
  12589. * @returns a ray in the direction the controller is pointing
  12590. */
  12591. getForwardRay(length?: number): Ray;
  12592. }
  12593. }
  12594. declare module BABYLON {
  12595. /**
  12596. * Defines the WebVRController object that represents controllers tracked in 3D space
  12597. */
  12598. export abstract class WebVRController extends PoseEnabledController {
  12599. /**
  12600. * Internal, the default controller model for the controller
  12601. */
  12602. protected _defaultModel: AbstractMesh;
  12603. /**
  12604. * Fired when the trigger state has changed
  12605. */
  12606. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12607. /**
  12608. * Fired when the main button state has changed
  12609. */
  12610. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12611. /**
  12612. * Fired when the secondary button state has changed
  12613. */
  12614. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12615. /**
  12616. * Fired when the pad state has changed
  12617. */
  12618. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12619. /**
  12620. * Fired when controllers stick values have changed
  12621. */
  12622. onPadValuesChangedObservable: Observable<StickValues>;
  12623. /**
  12624. * Array of button availible on the controller
  12625. */
  12626. protected _buttons: Array<MutableGamepadButton>;
  12627. private _onButtonStateChange;
  12628. /**
  12629. * Fired when a controller button's state has changed
  12630. * @param callback the callback containing the button that was modified
  12631. */
  12632. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12633. /**
  12634. * X and Y axis corrisponding to the controllers joystick
  12635. */
  12636. pad: StickValues;
  12637. /**
  12638. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12639. */
  12640. hand: string;
  12641. /**
  12642. * The default controller model for the controller
  12643. */
  12644. readonly defaultModel: AbstractMesh;
  12645. /**
  12646. * Creates a new WebVRController from a gamepad
  12647. * @param vrGamepad the gamepad that the WebVRController should be created from
  12648. */
  12649. constructor(vrGamepad: any);
  12650. /**
  12651. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12652. */
  12653. update(): void;
  12654. /**
  12655. * Function to be called when a button is modified
  12656. */
  12657. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12658. /**
  12659. * Loads a mesh and attaches it to the controller
  12660. * @param scene the scene the mesh should be added to
  12661. * @param meshLoaded callback for when the mesh has been loaded
  12662. */
  12663. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12664. private _setButtonValue;
  12665. private _changes;
  12666. private _checkChanges;
  12667. /**
  12668. * Disposes of th webVRCOntroller
  12669. */
  12670. dispose(): void;
  12671. }
  12672. }
  12673. declare module BABYLON {
  12674. /**
  12675. * The HemisphericLight simulates the ambient environment light,
  12676. * so the passed direction is the light reflection direction, not the incoming direction.
  12677. */
  12678. export class HemisphericLight extends Light {
  12679. /**
  12680. * The groundColor is the light in the opposite direction to the one specified during creation.
  12681. * 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.
  12682. */
  12683. groundColor: Color3;
  12684. /**
  12685. * The light reflection direction, not the incoming direction.
  12686. */
  12687. direction: Vector3;
  12688. /**
  12689. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12690. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12691. * The HemisphericLight can't cast shadows.
  12692. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12693. * @param name The friendly name of the light
  12694. * @param direction The direction of the light reflection
  12695. * @param scene The scene the light belongs to
  12696. */
  12697. constructor(name: string, direction: Vector3, scene: Scene);
  12698. protected _buildUniformLayout(): void;
  12699. /**
  12700. * Returns the string "HemisphericLight".
  12701. * @return The class name
  12702. */
  12703. getClassName(): string;
  12704. /**
  12705. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12706. * Returns the updated direction.
  12707. * @param target The target the direction should point to
  12708. * @return The computed direction
  12709. */
  12710. setDirectionToTarget(target: Vector3): Vector3;
  12711. /**
  12712. * Returns the shadow generator associated to the light.
  12713. * @returns Always null for hemispheric lights because it does not support shadows.
  12714. */
  12715. getShadowGenerator(): Nullable<IShadowGenerator>;
  12716. /**
  12717. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12718. * @param effect The effect to update
  12719. * @param lightIndex The index of the light in the effect to update
  12720. * @returns The hemispheric light
  12721. */
  12722. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12723. /**
  12724. * Computes the world matrix of the node
  12725. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12726. * @param useWasUpdatedFlag defines a reserved property
  12727. * @returns the world matrix
  12728. */
  12729. computeWorldMatrix(): Matrix;
  12730. /**
  12731. * Returns the integer 3.
  12732. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12733. */
  12734. getTypeID(): number;
  12735. /**
  12736. * Prepares the list of defines specific to the light type.
  12737. * @param defines the list of defines
  12738. * @param lightIndex defines the index of the light for the effect
  12739. */
  12740. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12741. }
  12742. }
  12743. declare module BABYLON {
  12744. /** @hidden */
  12745. export var vrMultiviewToSingleviewPixelShader: {
  12746. name: string;
  12747. shader: string;
  12748. };
  12749. }
  12750. declare module BABYLON {
  12751. /**
  12752. * Renders to multiple views with a single draw call
  12753. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  12754. */
  12755. export class MultiviewRenderTarget extends RenderTargetTexture {
  12756. /**
  12757. * Creates a multiview render target
  12758. * @param scene scene used with the render target
  12759. * @param size the size of the render target (used for each view)
  12760. */
  12761. constructor(scene: Scene, size?: number | {
  12762. width: number;
  12763. height: number;
  12764. } | {
  12765. ratio: number;
  12766. });
  12767. /**
  12768. * @hidden
  12769. * @param faceIndex the face index, if its a cube texture
  12770. */ bindFrameBuffer(faceIndex?: number): void;
  12771. /**
  12772. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  12773. * @returns the view count
  12774. */
  12775. getViewCount(): number;
  12776. }
  12777. }
  12778. declare module BABYLON {
  12779. interface Engine {
  12780. /**
  12781. * Creates a new multiview render target
  12782. * @param width defines the width of the texture
  12783. * @param height defines the height of the texture
  12784. * @returns the created multiview texture
  12785. */
  12786. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  12787. /**
  12788. * Binds a multiview framebuffer to be drawn to
  12789. * @param multiviewTexture texture to bind
  12790. */
  12791. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  12792. }
  12793. interface Camera {
  12794. /**
  12795. * @hidden
  12796. * 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)
  12797. */ useMultiviewToSingleView: boolean;
  12798. /**
  12799. * @hidden
  12800. * 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)
  12801. */ multiviewTexture: Nullable<RenderTargetTexture>;
  12802. /**
  12803. * @hidden
  12804. * ensures the multiview texture of the camera exists and has the specified width/height
  12805. * @param width height to set on the multiview texture
  12806. * @param height width to set on the multiview texture
  12807. */ resizeOrCreateMultiviewTexture(width: number, height: number): void;
  12808. }
  12809. interface Scene {
  12810. /** @hidden */ transformMatrixR: Matrix;
  12811. /** @hidden */ multiviewSceneUbo: Nullable<UniformBuffer>;
  12812. /** @hidden */ createMultiviewUbo(): void;
  12813. /** @hidden */ updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  12814. /** @hidden */ renderMultiviewToSingleView(camera: Camera): void;
  12815. }
  12816. }
  12817. declare module BABYLON {
  12818. /**
  12819. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  12820. * This will not be used for webXR as it supports displaying texture arrays directly
  12821. */
  12822. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  12823. /**
  12824. * Initializes a VRMultiviewToSingleview
  12825. * @param name name of the post process
  12826. * @param camera camera to be applied to
  12827. * @param scaleFactor scaling factor to the size of the output texture
  12828. */
  12829. constructor(name: string, camera: Camera, scaleFactor: number);
  12830. }
  12831. }
  12832. declare module BABYLON {
  12833. /**
  12834. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  12835. * IMPORTANT!! The data is right-hand data.
  12836. * @export
  12837. * @interface DevicePose
  12838. */
  12839. export interface DevicePose {
  12840. /**
  12841. * The position of the device, values in array are [x,y,z].
  12842. */
  12843. readonly position: Nullable<Float32Array>;
  12844. /**
  12845. * The linearVelocity of the device, values in array are [x,y,z].
  12846. */
  12847. readonly linearVelocity: Nullable<Float32Array>;
  12848. /**
  12849. * The linearAcceleration of the device, values in array are [x,y,z].
  12850. */
  12851. readonly linearAcceleration: Nullable<Float32Array>;
  12852. /**
  12853. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  12854. */
  12855. readonly orientation: Nullable<Float32Array>;
  12856. /**
  12857. * The angularVelocity of the device, values in array are [x,y,z].
  12858. */
  12859. readonly angularVelocity: Nullable<Float32Array>;
  12860. /**
  12861. * The angularAcceleration of the device, values in array are [x,y,z].
  12862. */
  12863. readonly angularAcceleration: Nullable<Float32Array>;
  12864. }
  12865. /**
  12866. * Interface representing a pose controlled object in Babylon.
  12867. * A pose controlled object has both regular pose values as well as pose values
  12868. * from an external device such as a VR head mounted display
  12869. */
  12870. export interface PoseControlled {
  12871. /**
  12872. * The position of the object in babylon space.
  12873. */
  12874. position: Vector3;
  12875. /**
  12876. * The rotation quaternion of the object in babylon space.
  12877. */
  12878. rotationQuaternion: Quaternion;
  12879. /**
  12880. * The position of the device in babylon space.
  12881. */
  12882. devicePosition?: Vector3;
  12883. /**
  12884. * The rotation quaternion of the device in babylon space.
  12885. */
  12886. deviceRotationQuaternion: Quaternion;
  12887. /**
  12888. * The raw pose coming from the device.
  12889. */
  12890. rawPose: Nullable<DevicePose>;
  12891. /**
  12892. * The scale of the device to be used when translating from device space to babylon space.
  12893. */
  12894. deviceScaleFactor: number;
  12895. /**
  12896. * Updates the poseControlled values based on the input device pose.
  12897. * @param poseData the pose data to update the object with
  12898. */
  12899. updateFromDevice(poseData: DevicePose): void;
  12900. }
  12901. /**
  12902. * Set of options to customize the webVRCamera
  12903. */
  12904. export interface WebVROptions {
  12905. /**
  12906. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  12907. */
  12908. trackPosition?: boolean;
  12909. /**
  12910. * Sets the scale of the vrDevice in babylon space. (default: 1)
  12911. */
  12912. positionScale?: number;
  12913. /**
  12914. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  12915. */
  12916. displayName?: string;
  12917. /**
  12918. * Should the native controller meshes be initialized. (default: true)
  12919. */
  12920. controllerMeshes?: boolean;
  12921. /**
  12922. * Creating a default HemiLight only on controllers. (default: true)
  12923. */
  12924. defaultLightingOnControllers?: boolean;
  12925. /**
  12926. * If you don't want to use the default VR button of the helper. (default: false)
  12927. */
  12928. useCustomVRButton?: boolean;
  12929. /**
  12930. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  12931. */
  12932. customVRButton?: HTMLButtonElement;
  12933. /**
  12934. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  12935. */
  12936. rayLength?: number;
  12937. /**
  12938. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  12939. */
  12940. defaultHeight?: number;
  12941. /**
  12942. * If multiview should be used if availible (default: false)
  12943. */
  12944. useMultiview?: boolean;
  12945. }
  12946. /**
  12947. * This represents a WebVR camera.
  12948. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  12949. * @example http://doc.babylonjs.com/how_to/webvr_camera
  12950. */
  12951. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  12952. private webVROptions;
  12953. /**
  12954. * @hidden
  12955. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  12956. */ vrDevice: any;
  12957. /**
  12958. * The rawPose of the vrDevice.
  12959. */
  12960. rawPose: Nullable<DevicePose>;
  12961. private _onVREnabled;
  12962. private _specsVersion;
  12963. private _attached;
  12964. private _frameData;
  12965. protected _descendants: Array<Node>;
  12966. private _deviceRoomPosition;
  12967. /** @hidden */ deviceRoomRotationQuaternion: Quaternion;
  12968. private _standingMatrix;
  12969. /**
  12970. * Represents device position in babylon space.
  12971. */
  12972. devicePosition: Vector3;
  12973. /**
  12974. * Represents device rotation in babylon space.
  12975. */
  12976. deviceRotationQuaternion: Quaternion;
  12977. /**
  12978. * The scale of the device to be used when translating from device space to babylon space.
  12979. */
  12980. deviceScaleFactor: number;
  12981. private _deviceToWorld;
  12982. private _worldToDevice;
  12983. /**
  12984. * References to the webVR controllers for the vrDevice.
  12985. */
  12986. controllers: Array<WebVRController>;
  12987. /**
  12988. * Emits an event when a controller is attached.
  12989. */
  12990. onControllersAttachedObservable: Observable<WebVRController[]>;
  12991. /**
  12992. * Emits an event when a controller's mesh has been loaded;
  12993. */
  12994. onControllerMeshLoadedObservable: Observable<WebVRController>;
  12995. /**
  12996. * Emits an event when the HMD's pose has been updated.
  12997. */
  12998. onPoseUpdatedFromDeviceObservable: Observable<any>;
  12999. private _poseSet;
  13000. /**
  13001. * If the rig cameras be used as parent instead of this camera.
  13002. */
  13003. rigParenting: boolean;
  13004. private _lightOnControllers;
  13005. private _defaultHeight?;
  13006. /**
  13007. * Instantiates a WebVRFreeCamera.
  13008. * @param name The name of the WebVRFreeCamera
  13009. * @param position The starting anchor position for the camera
  13010. * @param scene The scene the camera belongs to
  13011. * @param webVROptions a set of customizable options for the webVRCamera
  13012. */
  13013. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13014. /**
  13015. * Gets the device distance from the ground in meters.
  13016. * @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.
  13017. */
  13018. deviceDistanceToRoomGround(): number;
  13019. /**
  13020. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13021. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13022. */
  13023. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13024. /**
  13025. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13026. * @returns A promise with a boolean set to if the standing matrix is supported.
  13027. */
  13028. useStandingMatrixAsync(): Promise<boolean>;
  13029. /**
  13030. * Disposes the camera
  13031. */
  13032. dispose(): void;
  13033. /**
  13034. * Gets a vrController by name.
  13035. * @param name The name of the controller to retreive
  13036. * @returns the controller matching the name specified or null if not found
  13037. */
  13038. getControllerByName(name: string): Nullable<WebVRController>;
  13039. private _leftController;
  13040. /**
  13041. * The controller corrisponding to the users left hand.
  13042. */
  13043. readonly leftController: Nullable<WebVRController>;
  13044. private _rightController;
  13045. /**
  13046. * The controller corrisponding to the users right hand.
  13047. */
  13048. readonly rightController: Nullable<WebVRController>;
  13049. /**
  13050. * Casts a ray forward from the vrCamera's gaze.
  13051. * @param length Length of the ray (default: 100)
  13052. * @returns the ray corrisponding to the gaze
  13053. */
  13054. getForwardRay(length?: number): Ray;
  13055. /**
  13056. * @hidden
  13057. * Updates the camera based on device's frame data
  13058. */ checkInputs(): void;
  13059. /**
  13060. * Updates the poseControlled values based on the input device pose.
  13061. * @param poseData Pose coming from the device
  13062. */
  13063. updateFromDevice(poseData: DevicePose): void;
  13064. private _htmlElementAttached;
  13065. private _detachIfAttached;
  13066. /**
  13067. * WebVR's attach control will start broadcasting frames to the device.
  13068. * Note that in certain browsers (chrome for example) this function must be called
  13069. * within a user-interaction callback. Example:
  13070. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13071. *
  13072. * @param element html element to attach the vrDevice to
  13073. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13074. */
  13075. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13076. /**
  13077. * Detaches the camera from the html element and disables VR
  13078. *
  13079. * @param element html element to detach from
  13080. */
  13081. detachControl(element: HTMLElement): void;
  13082. /**
  13083. * @returns the name of this class
  13084. */
  13085. getClassName(): string;
  13086. /**
  13087. * Calls resetPose on the vrDisplay
  13088. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13089. */
  13090. resetToCurrentRotation(): void;
  13091. /**
  13092. * @hidden
  13093. * Updates the rig cameras (left and right eye)
  13094. */ updateRigCameras(): void;
  13095. private _workingVector;
  13096. private _oneVector;
  13097. private _workingMatrix;
  13098. private updateCacheCalled;
  13099. private _correctPositionIfNotTrackPosition;
  13100. /**
  13101. * @hidden
  13102. * Updates the cached values of the camera
  13103. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13104. */ updateCache(ignoreParentClass?: boolean): void;
  13105. /**
  13106. * @hidden
  13107. * Get current device position in babylon world
  13108. */ computeDevicePosition(): void;
  13109. /**
  13110. * Updates the current device position and rotation in the babylon world
  13111. */
  13112. update(): void;
  13113. /**
  13114. * @hidden
  13115. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13116. * @returns an identity matrix
  13117. */ getViewMatrix(): Matrix;
  13118. private _tmpMatrix;
  13119. /**
  13120. * This function is called by the two RIG cameras.
  13121. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13122. * @hidden
  13123. */ getWebVRViewMatrix(): Matrix;
  13124. /** @hidden */ getWebVRProjectionMatrix(): Matrix;
  13125. private _onGamepadConnectedObserver;
  13126. private _onGamepadDisconnectedObserver;
  13127. private _updateCacheWhenTrackingDisabledObserver;
  13128. /**
  13129. * Initializes the controllers and their meshes
  13130. */
  13131. initControllers(): void;
  13132. }
  13133. }
  13134. declare module BABYLON {
  13135. /**
  13136. * Size options for a post process
  13137. */
  13138. export type PostProcessOptions = {
  13139. width: number;
  13140. height: number;
  13141. };
  13142. /**
  13143. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13144. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13145. */
  13146. export class PostProcess {
  13147. /** Name of the PostProcess. */
  13148. name: string;
  13149. /**
  13150. * Gets or sets the unique id of the post process
  13151. */
  13152. uniqueId: number;
  13153. /**
  13154. * Width of the texture to apply the post process on
  13155. */
  13156. width: number;
  13157. /**
  13158. * Height of the texture to apply the post process on
  13159. */
  13160. height: number;
  13161. /**
  13162. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13163. * @hidden
  13164. */ outputTexture: Nullable<InternalTexture>;
  13165. /**
  13166. * Sampling mode used by the shader
  13167. * See https://doc.babylonjs.com/classes/3.1/texture
  13168. */
  13169. renderTargetSamplingMode: number;
  13170. /**
  13171. * Clear color to use when screen clearing
  13172. */
  13173. clearColor: Color4;
  13174. /**
  13175. * If the buffer needs to be cleared before applying the post process. (default: true)
  13176. * Should be set to false if shader will overwrite all previous pixels.
  13177. */
  13178. autoClear: boolean;
  13179. /**
  13180. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13181. */
  13182. alphaMode: number;
  13183. /**
  13184. * Sets the setAlphaBlendConstants of the babylon engine
  13185. */
  13186. alphaConstants: Color4;
  13187. /**
  13188. * Animations to be used for the post processing
  13189. */
  13190. animations: Animation[];
  13191. /**
  13192. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13193. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13194. */
  13195. enablePixelPerfectMode: boolean;
  13196. /**
  13197. * Force the postprocess to be applied without taking in account viewport
  13198. */
  13199. forceFullscreenViewport: boolean;
  13200. /**
  13201. * List of inspectable custom properties (used by the Inspector)
  13202. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13203. */
  13204. inspectableCustomProperties: IInspectable[];
  13205. /**
  13206. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13207. *
  13208. * | Value | Type | Description |
  13209. * | ----- | ----------------------------------- | ----------- |
  13210. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13211. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13212. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13213. *
  13214. */
  13215. scaleMode: number;
  13216. /**
  13217. * Force textures to be a power of two (default: false)
  13218. */
  13219. alwaysForcePOT: boolean;
  13220. private _samples;
  13221. /**
  13222. * Number of sample textures (default: 1)
  13223. */
  13224. samples: number;
  13225. /**
  13226. * Modify the scale of the post process to be the same as the viewport (default: false)
  13227. */
  13228. adaptScaleToCurrentViewport: boolean;
  13229. private _camera;
  13230. private _scene;
  13231. private _engine;
  13232. private _options;
  13233. private _reusable;
  13234. private _textureType;
  13235. /**
  13236. * Smart array of input and output textures for the post process.
  13237. * @hidden
  13238. */ textures: SmartArray<InternalTexture>;
  13239. /**
  13240. * The index in _textures that corresponds to the output texture.
  13241. * @hidden
  13242. */ currentRenderTextureInd: number;
  13243. private _effect;
  13244. private _samplers;
  13245. private _fragmentUrl;
  13246. private _vertexUrl;
  13247. private _parameters;
  13248. private _scaleRatio;
  13249. protected _indexParameters: any;
  13250. private _shareOutputWithPostProcess;
  13251. private _texelSize;
  13252. private _forcedOutputTexture;
  13253. /**
  13254. * Returns the fragment url or shader name used in the post process.
  13255. * @returns the fragment url or name in the shader store.
  13256. */
  13257. getEffectName(): string;
  13258. /**
  13259. * An event triggered when the postprocess is activated.
  13260. */
  13261. onActivateObservable: Observable<Camera>;
  13262. private _onActivateObserver;
  13263. /**
  13264. * A function that is added to the onActivateObservable
  13265. */
  13266. onActivate: Nullable<(camera: Camera) => void>;
  13267. /**
  13268. * An event triggered when the postprocess changes its size.
  13269. */
  13270. onSizeChangedObservable: Observable<PostProcess>;
  13271. private _onSizeChangedObserver;
  13272. /**
  13273. * A function that is added to the onSizeChangedObservable
  13274. */
  13275. onSizeChanged: (postProcess: PostProcess) => void;
  13276. /**
  13277. * An event triggered when the postprocess applies its effect.
  13278. */
  13279. onApplyObservable: Observable<Effect>;
  13280. private _onApplyObserver;
  13281. /**
  13282. * A function that is added to the onApplyObservable
  13283. */
  13284. onApply: (effect: Effect) => void;
  13285. /**
  13286. * An event triggered before rendering the postprocess
  13287. */
  13288. onBeforeRenderObservable: Observable<Effect>;
  13289. private _onBeforeRenderObserver;
  13290. /**
  13291. * A function that is added to the onBeforeRenderObservable
  13292. */
  13293. onBeforeRender: (effect: Effect) => void;
  13294. /**
  13295. * An event triggered after rendering the postprocess
  13296. */
  13297. onAfterRenderObservable: Observable<Effect>;
  13298. private _onAfterRenderObserver;
  13299. /**
  13300. * A function that is added to the onAfterRenderObservable
  13301. */
  13302. onAfterRender: (efect: Effect) => void;
  13303. /**
  13304. * 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
  13305. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13306. */
  13307. inputTexture: InternalTexture;
  13308. /**
  13309. * Gets the camera which post process is applied to.
  13310. * @returns The camera the post process is applied to.
  13311. */
  13312. getCamera(): Camera;
  13313. /**
  13314. * Gets the texel size of the postprocess.
  13315. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13316. */
  13317. readonly texelSize: Vector2;
  13318. /**
  13319. * Creates a new instance PostProcess
  13320. * @param name The name of the PostProcess.
  13321. * @param fragmentUrl The url of the fragment shader to be used.
  13322. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13323. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13324. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13325. * @param camera The camera to apply the render pass to.
  13326. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13327. * @param engine The engine which the post process will be applied. (default: current engine)
  13328. * @param reusable If the post process can be reused on the same frame. (default: false)
  13329. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13330. * @param textureType Type of textures used when performing the post process. (default: 0)
  13331. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13332. * @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
  13333. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13334. */
  13335. constructor(
  13336. /** Name of the PostProcess. */
  13337. 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);
  13338. /**
  13339. * Gets a string idenfifying the name of the class
  13340. * @returns "PostProcess" string
  13341. */
  13342. getClassName(): string;
  13343. /**
  13344. * Gets the engine which this post process belongs to.
  13345. * @returns The engine the post process was enabled with.
  13346. */
  13347. getEngine(): Engine;
  13348. /**
  13349. * The effect that is created when initializing the post process.
  13350. * @returns The created effect corrisponding the the postprocess.
  13351. */
  13352. getEffect(): Effect;
  13353. /**
  13354. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13355. * @param postProcess The post process to share the output with.
  13356. * @returns This post process.
  13357. */
  13358. shareOutputWith(postProcess: PostProcess): PostProcess;
  13359. /**
  13360. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13361. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13362. */
  13363. useOwnOutput(): void;
  13364. /**
  13365. * Updates the effect with the current post process compile time values and recompiles the shader.
  13366. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13367. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13368. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13369. * @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
  13370. * @param onCompiled Called when the shader has been compiled.
  13371. * @param onError Called if there is an error when compiling a shader.
  13372. */
  13373. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13374. /**
  13375. * The post process is reusable if it can be used multiple times within one frame.
  13376. * @returns If the post process is reusable
  13377. */
  13378. isReusable(): boolean;
  13379. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13380. markTextureDirty(): void;
  13381. /**
  13382. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13383. * 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.
  13384. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13385. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13386. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13387. * @returns The target texture that was bound to be written to.
  13388. */
  13389. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13390. /**
  13391. * If the post process is supported.
  13392. */
  13393. readonly isSupported: boolean;
  13394. /**
  13395. * The aspect ratio of the output texture.
  13396. */
  13397. readonly aspectRatio: number;
  13398. /**
  13399. * Get a value indicating if the post-process is ready to be used
  13400. * @returns true if the post-process is ready (shader is compiled)
  13401. */
  13402. isReady(): boolean;
  13403. /**
  13404. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13405. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13406. */
  13407. apply(): Nullable<Effect>;
  13408. private _disposeTextures;
  13409. /**
  13410. * Disposes the post process.
  13411. * @param camera The camera to dispose the post process on.
  13412. */
  13413. dispose(camera?: Camera): void;
  13414. }
  13415. }
  13416. declare module BABYLON {
  13417. /**
  13418. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13419. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13420. */
  13421. export class PostProcessManager {
  13422. private _scene;
  13423. private _indexBuffer;
  13424. private _vertexBuffers;
  13425. /**
  13426. * Creates a new instance PostProcess
  13427. * @param scene The scene that the post process is associated with.
  13428. */
  13429. constructor(scene: Scene);
  13430. private _prepareBuffers;
  13431. private _buildIndexBuffer;
  13432. /**
  13433. * Rebuilds the vertex buffers of the manager.
  13434. * @hidden
  13435. */ rebuild(): void;
  13436. /**
  13437. * Prepares a frame to be run through a post process.
  13438. * @param sourceTexture The input texture to the post procesess. (default: null)
  13439. * @param postProcesses An array of post processes to be run. (default: null)
  13440. * @returns True if the post processes were able to be run.
  13441. * @hidden
  13442. */ prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13443. /**
  13444. * Manually render a set of post processes to a texture.
  13445. * @param postProcesses An array of post processes to be run.
  13446. * @param targetTexture The target texture to render to.
  13447. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13448. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13449. * @param lodLevel defines which lod of the texture to render to
  13450. */
  13451. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13452. /**
  13453. * Finalize the result of the output of the postprocesses.
  13454. * @param doNotPresent If true the result will not be displayed to the screen.
  13455. * @param targetTexture The target texture to render to.
  13456. * @param faceIndex The index of the face to bind the target texture to.
  13457. * @param postProcesses The array of post processes to render.
  13458. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13459. * @hidden
  13460. */ finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13461. /**
  13462. * Disposes of the post process manager.
  13463. */
  13464. dispose(): void;
  13465. }
  13466. }
  13467. declare module BABYLON {
  13468. interface AbstractScene {
  13469. /**
  13470. * The list of layers (background and foreground) of the scene
  13471. */
  13472. layers: Array<Layer>;
  13473. }
  13474. /**
  13475. * Defines the layer scene component responsible to manage any layers
  13476. * in a given scene.
  13477. */
  13478. export class LayerSceneComponent implements ISceneComponent {
  13479. /**
  13480. * The component name helpfull to identify the component in the list of scene components.
  13481. */
  13482. readonly name: string;
  13483. /**
  13484. * The scene the component belongs to.
  13485. */
  13486. scene: Scene;
  13487. private _engine;
  13488. /**
  13489. * Creates a new instance of the component for the given scene
  13490. * @param scene Defines the scene to register the component in
  13491. */
  13492. constructor(scene: Scene);
  13493. /**
  13494. * Registers the component in a given scene
  13495. */
  13496. register(): void;
  13497. /**
  13498. * Rebuilds the elements related to this component in case of
  13499. * context lost for instance.
  13500. */
  13501. rebuild(): void;
  13502. /**
  13503. * Disposes the component and the associated ressources.
  13504. */
  13505. dispose(): void;
  13506. private _draw;
  13507. private _drawCameraPredicate;
  13508. private _drawCameraBackground;
  13509. private _drawCameraForeground;
  13510. private _drawRenderTargetPredicate;
  13511. private _drawRenderTargetBackground;
  13512. private _drawRenderTargetForeground;
  13513. }
  13514. }
  13515. declare module BABYLON {
  13516. /** @hidden */
  13517. export var layerPixelShader: {
  13518. name: string;
  13519. shader: string;
  13520. };
  13521. }
  13522. declare module BABYLON {
  13523. /** @hidden */
  13524. export var layerVertexShader: {
  13525. name: string;
  13526. shader: string;
  13527. };
  13528. }
  13529. declare module BABYLON {
  13530. /**
  13531. * This represents a full screen 2d layer.
  13532. * This can be useful to display a picture in the background of your scene for instance.
  13533. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13534. */
  13535. export class Layer {
  13536. /**
  13537. * Define the name of the layer.
  13538. */
  13539. name: string;
  13540. /**
  13541. * Define the texture the layer should display.
  13542. */
  13543. texture: Nullable<Texture>;
  13544. /**
  13545. * Is the layer in background or foreground.
  13546. */
  13547. isBackground: boolean;
  13548. /**
  13549. * Define the color of the layer (instead of texture).
  13550. */
  13551. color: Color4;
  13552. /**
  13553. * Define the scale of the layer in order to zoom in out of the texture.
  13554. */
  13555. scale: Vector2;
  13556. /**
  13557. * Define an offset for the layer in order to shift the texture.
  13558. */
  13559. offset: Vector2;
  13560. /**
  13561. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13562. */
  13563. alphaBlendingMode: number;
  13564. /**
  13565. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13566. * Alpha test will not mix with the background color in case of transparency.
  13567. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13568. */
  13569. alphaTest: boolean;
  13570. /**
  13571. * Define a mask to restrict the layer to only some of the scene cameras.
  13572. */
  13573. layerMask: number;
  13574. /**
  13575. * Define the list of render target the layer is visible into.
  13576. */
  13577. renderTargetTextures: RenderTargetTexture[];
  13578. /**
  13579. * Define if the layer is only used in renderTarget or if it also
  13580. * renders in the main frame buffer of the canvas.
  13581. */
  13582. renderOnlyInRenderTargetTextures: boolean;
  13583. private _scene;
  13584. private _vertexBuffers;
  13585. private _indexBuffer;
  13586. private _effect;
  13587. private _alphaTestEffect;
  13588. /**
  13589. * An event triggered when the layer is disposed.
  13590. */
  13591. onDisposeObservable: Observable<Layer>;
  13592. private _onDisposeObserver;
  13593. /**
  13594. * Back compatibility with callback before the onDisposeObservable existed.
  13595. * The set callback will be triggered when the layer has been disposed.
  13596. */
  13597. onDispose: () => void;
  13598. /**
  13599. * An event triggered before rendering the scene
  13600. */
  13601. onBeforeRenderObservable: Observable<Layer>;
  13602. private _onBeforeRenderObserver;
  13603. /**
  13604. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13605. * The set callback will be triggered just before rendering the layer.
  13606. */
  13607. onBeforeRender: () => void;
  13608. /**
  13609. * An event triggered after rendering the scene
  13610. */
  13611. onAfterRenderObservable: Observable<Layer>;
  13612. private _onAfterRenderObserver;
  13613. /**
  13614. * Back compatibility with callback before the onAfterRenderObservable existed.
  13615. * The set callback will be triggered just after rendering the layer.
  13616. */
  13617. onAfterRender: () => void;
  13618. /**
  13619. * Instantiates a new layer.
  13620. * This represents a full screen 2d layer.
  13621. * This can be useful to display a picture in the background of your scene for instance.
  13622. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13623. * @param name Define the name of the layer in the scene
  13624. * @param imgUrl Define the url of the texture to display in the layer
  13625. * @param scene Define the scene the layer belongs to
  13626. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13627. * @param color Defines a color for the layer
  13628. */
  13629. constructor(
  13630. /**
  13631. * Define the name of the layer.
  13632. */
  13633. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13634. private _createIndexBuffer;
  13635. /** @hidden */ rebuild(): void;
  13636. /**
  13637. * Renders the layer in the scene.
  13638. */
  13639. render(): void;
  13640. /**
  13641. * Disposes and releases the associated ressources.
  13642. */
  13643. dispose(): void;
  13644. }
  13645. }
  13646. declare module BABYLON {
  13647. interface AbstractScene {
  13648. /**
  13649. * The list of procedural textures added to the scene
  13650. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13651. */
  13652. proceduralTextures: Array<ProceduralTexture>;
  13653. }
  13654. /**
  13655. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13656. * in a given scene.
  13657. */
  13658. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13659. /**
  13660. * The component name helpfull to identify the component in the list of scene components.
  13661. */
  13662. readonly name: string;
  13663. /**
  13664. * The scene the component belongs to.
  13665. */
  13666. scene: Scene;
  13667. /**
  13668. * Creates a new instance of the component for the given scene
  13669. * @param scene Defines the scene to register the component in
  13670. */
  13671. constructor(scene: Scene);
  13672. /**
  13673. * Registers the component in a given scene
  13674. */
  13675. register(): void;
  13676. /**
  13677. * Rebuilds the elements related to this component in case of
  13678. * context lost for instance.
  13679. */
  13680. rebuild(): void;
  13681. /**
  13682. * Disposes the component and the associated ressources.
  13683. */
  13684. dispose(): void;
  13685. private _beforeClear;
  13686. }
  13687. }
  13688. declare module BABYLON {
  13689. /** @hidden */
  13690. export var proceduralVertexShader: {
  13691. name: string;
  13692. shader: string;
  13693. };
  13694. }
  13695. declare module BABYLON {
  13696. /**
  13697. * 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.
  13698. * This is the base class of any Procedural texture and contains most of the shareable code.
  13699. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13700. */
  13701. export class ProceduralTexture extends Texture {
  13702. isCube: boolean;
  13703. /**
  13704. * Define if the texture is enabled or not (disabled texture will not render)
  13705. */
  13706. isEnabled: boolean;
  13707. /**
  13708. * Define if the texture must be cleared before rendering (default is true)
  13709. */
  13710. autoClear: boolean;
  13711. /**
  13712. * Callback called when the texture is generated
  13713. */
  13714. onGenerated: () => void;
  13715. /**
  13716. * Event raised when the texture is generated
  13717. */
  13718. onGeneratedObservable: Observable<ProceduralTexture>;
  13719. /** @hidden */ generateMipMaps: boolean;
  13720. /** @hidden **/ effect: Effect;
  13721. /** @hidden */ textures: {
  13722. [key: string]: Texture;
  13723. };
  13724. private _size;
  13725. private _currentRefreshId;
  13726. private _refreshRate;
  13727. private _vertexBuffers;
  13728. private _indexBuffer;
  13729. private _uniforms;
  13730. private _samplers;
  13731. private _fragment;
  13732. private _floats;
  13733. private _ints;
  13734. private _floatsArrays;
  13735. private _colors3;
  13736. private _colors4;
  13737. private _vectors2;
  13738. private _vectors3;
  13739. private _matrices;
  13740. private _fallbackTexture;
  13741. private _fallbackTextureUsed;
  13742. private _engine;
  13743. private _cachedDefines;
  13744. private _contentUpdateId;
  13745. private _contentData;
  13746. /**
  13747. * Instantiates a new procedural texture.
  13748. * 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.
  13749. * This is the base class of any Procedural texture and contains most of the shareable code.
  13750. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13751. * @param name Define the name of the texture
  13752. * @param size Define the size of the texture to create
  13753. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13754. * @param scene Define the scene the texture belongs to
  13755. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13756. * @param generateMipMaps Define if the texture should creates mip maps or not
  13757. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13758. */
  13759. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13760. /**
  13761. * The effect that is created when initializing the post process.
  13762. * @returns The created effect corrisponding the the postprocess.
  13763. */
  13764. getEffect(): Effect;
  13765. /**
  13766. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13767. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13768. */
  13769. getContent(): Nullable<ArrayBufferView>;
  13770. private _createIndexBuffer;
  13771. /** @hidden */ rebuild(): void;
  13772. /**
  13773. * Resets the texture in order to recreate its associated resources.
  13774. * This can be called in case of context loss
  13775. */
  13776. reset(): void;
  13777. protected _getDefines(): string;
  13778. /**
  13779. * Is the texture ready to be used ? (rendered at least once)
  13780. * @returns true if ready, otherwise, false.
  13781. */
  13782. isReady(): boolean;
  13783. /**
  13784. * Resets the refresh counter of the texture and start bak from scratch.
  13785. * Could be useful to regenerate the texture if it is setup to render only once.
  13786. */
  13787. resetRefreshCounter(): void;
  13788. /**
  13789. * Set the fragment shader to use in order to render the texture.
  13790. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  13791. */
  13792. setFragment(fragment: any): void;
  13793. /**
  13794. * Define the refresh rate of the texture or the rendering frequency.
  13795. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  13796. */
  13797. refreshRate: number;
  13798. /** @hidden */ shouldRender(): boolean;
  13799. /**
  13800. * Get the size the texture is rendering at.
  13801. * @returns the size (texture is always squared)
  13802. */
  13803. getRenderSize(): number;
  13804. /**
  13805. * Resize the texture to new value.
  13806. * @param size Define the new size the texture should have
  13807. * @param generateMipMaps Define whether the new texture should create mip maps
  13808. */
  13809. resize(size: number, generateMipMaps: boolean): void;
  13810. private _checkUniform;
  13811. /**
  13812. * Set a texture in the shader program used to render.
  13813. * @param name Define the name of the uniform samplers as defined in the shader
  13814. * @param texture Define the texture to bind to this sampler
  13815. * @return the texture itself allowing "fluent" like uniform updates
  13816. */
  13817. setTexture(name: string, texture: Texture): ProceduralTexture;
  13818. /**
  13819. * Set a float in the shader.
  13820. * @param name Define the name of the uniform as defined in the shader
  13821. * @param value Define the value to give to the uniform
  13822. * @return the texture itself allowing "fluent" like uniform updates
  13823. */
  13824. setFloat(name: string, value: number): ProceduralTexture;
  13825. /**
  13826. * Set a int in the shader.
  13827. * @param name Define the name of the uniform as defined in the shader
  13828. * @param value Define the value to give to the uniform
  13829. * @return the texture itself allowing "fluent" like uniform updates
  13830. */
  13831. setInt(name: string, value: number): ProceduralTexture;
  13832. /**
  13833. * Set an array of floats in the shader.
  13834. * @param name Define the name of the uniform as defined in the shader
  13835. * @param value Define the value to give to the uniform
  13836. * @return the texture itself allowing "fluent" like uniform updates
  13837. */
  13838. setFloats(name: string, value: number[]): ProceduralTexture;
  13839. /**
  13840. * Set a vec3 in the shader from a Color3.
  13841. * @param name Define the name of the uniform as defined in the shader
  13842. * @param value Define the value to give to the uniform
  13843. * @return the texture itself allowing "fluent" like uniform updates
  13844. */
  13845. setColor3(name: string, value: Color3): ProceduralTexture;
  13846. /**
  13847. * Set a vec4 in the shader from a Color4.
  13848. * @param name Define the name of the uniform as defined in the shader
  13849. * @param value Define the value to give to the uniform
  13850. * @return the texture itself allowing "fluent" like uniform updates
  13851. */
  13852. setColor4(name: string, value: Color4): ProceduralTexture;
  13853. /**
  13854. * Set a vec2 in the shader from a Vector2.
  13855. * @param name Define the name of the uniform as defined in the shader
  13856. * @param value Define the value to give to the uniform
  13857. * @return the texture itself allowing "fluent" like uniform updates
  13858. */
  13859. setVector2(name: string, value: Vector2): ProceduralTexture;
  13860. /**
  13861. * Set a vec3 in the shader from a Vector3.
  13862. * @param name Define the name of the uniform as defined in the shader
  13863. * @param value Define the value to give to the uniform
  13864. * @return the texture itself allowing "fluent" like uniform updates
  13865. */
  13866. setVector3(name: string, value: Vector3): ProceduralTexture;
  13867. /**
  13868. * Set a mat4 in the shader from a MAtrix.
  13869. * @param name Define the name of the uniform as defined in the shader
  13870. * @param value Define the value to give to the uniform
  13871. * @return the texture itself allowing "fluent" like uniform updates
  13872. */
  13873. setMatrix(name: string, value: Matrix): ProceduralTexture;
  13874. /**
  13875. * Render the texture to its associated render target.
  13876. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  13877. */
  13878. render(useCameraPostProcess?: boolean): void;
  13879. /**
  13880. * Clone the texture.
  13881. * @returns the cloned texture
  13882. */
  13883. clone(): ProceduralTexture;
  13884. /**
  13885. * Dispose the texture and release its asoociated resources.
  13886. */
  13887. dispose(): void;
  13888. }
  13889. }
  13890. declare module BABYLON {
  13891. /**
  13892. * This represents the base class for particle system in Babylon.
  13893. * 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.
  13894. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  13895. * @example https://doc.babylonjs.com/babylon101/particles
  13896. */
  13897. export class BaseParticleSystem {
  13898. /**
  13899. * Source color is added to the destination color without alpha affecting the result
  13900. */
  13901. static BLENDMODE_ONEONE: number;
  13902. /**
  13903. * Blend current color and particle color using particle’s alpha
  13904. */
  13905. static BLENDMODE_STANDARD: number;
  13906. /**
  13907. * Add current color and particle color multiplied by particle’s alpha
  13908. */
  13909. static BLENDMODE_ADD: number;
  13910. /**
  13911. * Multiply current color with particle color
  13912. */
  13913. static BLENDMODE_MULTIPLY: number;
  13914. /**
  13915. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  13916. */
  13917. static BLENDMODE_MULTIPLYADD: number;
  13918. /**
  13919. * List of animations used by the particle system.
  13920. */
  13921. animations: Animation[];
  13922. /**
  13923. * The id of the Particle system.
  13924. */
  13925. id: string;
  13926. /**
  13927. * The friendly name of the Particle system.
  13928. */
  13929. name: string;
  13930. /**
  13931. * The rendering group used by the Particle system to chose when to render.
  13932. */
  13933. renderingGroupId: number;
  13934. /**
  13935. * The emitter represents the Mesh or position we are attaching the particle system to.
  13936. */
  13937. emitter: Nullable<AbstractMesh | Vector3>;
  13938. /**
  13939. * The maximum number of particles to emit per frame
  13940. */
  13941. emitRate: number;
  13942. /**
  13943. * If you want to launch only a few particles at once, that can be done, as well.
  13944. */
  13945. manualEmitCount: number;
  13946. /**
  13947. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13948. */
  13949. updateSpeed: number;
  13950. /**
  13951. * The amount of time the particle system is running (depends of the overall update speed).
  13952. */
  13953. targetStopDuration: number;
  13954. /**
  13955. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13956. */
  13957. disposeOnStop: boolean;
  13958. /**
  13959. * Minimum power of emitting particles.
  13960. */
  13961. minEmitPower: number;
  13962. /**
  13963. * Maximum power of emitting particles.
  13964. */
  13965. maxEmitPower: number;
  13966. /**
  13967. * Minimum life time of emitting particles.
  13968. */
  13969. minLifeTime: number;
  13970. /**
  13971. * Maximum life time of emitting particles.
  13972. */
  13973. maxLifeTime: number;
  13974. /**
  13975. * Minimum Size of emitting particles.
  13976. */
  13977. minSize: number;
  13978. /**
  13979. * Maximum Size of emitting particles.
  13980. */
  13981. maxSize: number;
  13982. /**
  13983. * Minimum scale of emitting particles on X axis.
  13984. */
  13985. minScaleX: number;
  13986. /**
  13987. * Maximum scale of emitting particles on X axis.
  13988. */
  13989. maxScaleX: number;
  13990. /**
  13991. * Minimum scale of emitting particles on Y axis.
  13992. */
  13993. minScaleY: number;
  13994. /**
  13995. * Maximum scale of emitting particles on Y axis.
  13996. */
  13997. maxScaleY: number;
  13998. /**
  13999. * Gets or sets the minimal initial rotation in radians.
  14000. */
  14001. minInitialRotation: number;
  14002. /**
  14003. * Gets or sets the maximal initial rotation in radians.
  14004. */
  14005. maxInitialRotation: number;
  14006. /**
  14007. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14008. */
  14009. minAngularSpeed: number;
  14010. /**
  14011. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14012. */
  14013. maxAngularSpeed: number;
  14014. /**
  14015. * The texture used to render each particle. (this can be a spritesheet)
  14016. */
  14017. particleTexture: Nullable<Texture>;
  14018. /**
  14019. * The layer mask we are rendering the particles through.
  14020. */
  14021. layerMask: number;
  14022. /**
  14023. * This can help using your own shader to render the particle system.
  14024. * The according effect will be created
  14025. */
  14026. customShader: any;
  14027. /**
  14028. * By default particle system starts as soon as they are created. This prevents the
  14029. * automatic start to happen and let you decide when to start emitting particles.
  14030. */
  14031. preventAutoStart: boolean;
  14032. private _noiseTexture;
  14033. /**
  14034. * Gets or sets a texture used to add random noise to particle positions
  14035. */
  14036. noiseTexture: Nullable<ProceduralTexture>;
  14037. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14038. noiseStrength: Vector3;
  14039. /**
  14040. * Callback triggered when the particle animation is ending.
  14041. */
  14042. onAnimationEnd: Nullable<() => void>;
  14043. /**
  14044. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14045. */
  14046. blendMode: number;
  14047. /**
  14048. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14049. * to override the particles.
  14050. */
  14051. forceDepthWrite: boolean;
  14052. /** 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 */
  14053. preWarmCycles: number;
  14054. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14055. preWarmStepOffset: number;
  14056. /**
  14057. * 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)
  14058. */
  14059. spriteCellChangeSpeed: number;
  14060. /**
  14061. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14062. */
  14063. startSpriteCellID: number;
  14064. /**
  14065. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14066. */
  14067. endSpriteCellID: number;
  14068. /**
  14069. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14070. */
  14071. spriteCellWidth: number;
  14072. /**
  14073. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14074. */
  14075. spriteCellHeight: number;
  14076. /**
  14077. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14078. */
  14079. spriteRandomStartCell: boolean;
  14080. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14081. translationPivot: Vector2;
  14082. /** @hidden */
  14083. protected _isAnimationSheetEnabled: boolean;
  14084. /**
  14085. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14086. */
  14087. beginAnimationOnStart: boolean;
  14088. /**
  14089. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14090. */
  14091. beginAnimationFrom: number;
  14092. /**
  14093. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14094. */
  14095. beginAnimationTo: number;
  14096. /**
  14097. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14098. */
  14099. beginAnimationLoop: boolean;
  14100. /**
  14101. * Gets or sets a world offset applied to all particles
  14102. */
  14103. worldOffset: Vector3;
  14104. /**
  14105. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14106. */
  14107. isAnimationSheetEnabled: boolean;
  14108. /**
  14109. * Get hosting scene
  14110. * @returns the scene
  14111. */
  14112. getScene(): Scene;
  14113. /**
  14114. * You can use gravity if you want to give an orientation to your particles.
  14115. */
  14116. gravity: Vector3;
  14117. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14118. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14119. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14120. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14121. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14122. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14123. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14124. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14125. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14126. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14127. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14128. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14129. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14130. /**
  14131. * Defines the delay in milliseconds before starting the system (0 by default)
  14132. */
  14133. startDelay: number;
  14134. /**
  14135. * Gets the current list of drag gradients.
  14136. * You must use addDragGradient and removeDragGradient to udpate this list
  14137. * @returns the list of drag gradients
  14138. */
  14139. getDragGradients(): Nullable<Array<FactorGradient>>;
  14140. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14141. limitVelocityDamping: number;
  14142. /**
  14143. * Gets the current list of limit velocity gradients.
  14144. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14145. * @returns the list of limit velocity gradients
  14146. */
  14147. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14148. /**
  14149. * Gets the current list of color gradients.
  14150. * You must use addColorGradient and removeColorGradient to udpate this list
  14151. * @returns the list of color gradients
  14152. */
  14153. getColorGradients(): Nullable<Array<ColorGradient>>;
  14154. /**
  14155. * Gets the current list of size gradients.
  14156. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14157. * @returns the list of size gradients
  14158. */
  14159. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14160. /**
  14161. * Gets the current list of color remap gradients.
  14162. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14163. * @returns the list of color remap gradients
  14164. */
  14165. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14166. /**
  14167. * Gets the current list of alpha remap gradients.
  14168. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14169. * @returns the list of alpha remap gradients
  14170. */
  14171. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14172. /**
  14173. * Gets the current list of life time gradients.
  14174. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14175. * @returns the list of life time gradients
  14176. */
  14177. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14178. /**
  14179. * Gets the current list of angular speed gradients.
  14180. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14181. * @returns the list of angular speed gradients
  14182. */
  14183. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14184. /**
  14185. * Gets the current list of velocity gradients.
  14186. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14187. * @returns the list of velocity gradients
  14188. */
  14189. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14190. /**
  14191. * Gets the current list of start size gradients.
  14192. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14193. * @returns the list of start size gradients
  14194. */
  14195. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14196. /**
  14197. * Gets the current list of emit rate gradients.
  14198. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14199. * @returns the list of emit rate gradients
  14200. */
  14201. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14202. /**
  14203. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14204. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14205. */
  14206. direction1: Vector3;
  14207. /**
  14208. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14209. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14210. */
  14211. direction2: Vector3;
  14212. /**
  14213. * 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.
  14214. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14215. */
  14216. minEmitBox: Vector3;
  14217. /**
  14218. * 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.
  14219. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14220. */
  14221. maxEmitBox: Vector3;
  14222. /**
  14223. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14224. */
  14225. color1: Color4;
  14226. /**
  14227. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14228. */
  14229. color2: Color4;
  14230. /**
  14231. * Color the particle will have at the end of its lifetime
  14232. */
  14233. colorDead: Color4;
  14234. /**
  14235. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14236. */
  14237. textureMask: Color4;
  14238. /**
  14239. * The particle emitter type defines the emitter used by the particle system.
  14240. * It can be for example box, sphere, or cone...
  14241. */
  14242. particleEmitterType: IParticleEmitterType;
  14243. /** @hidden */ isSubEmitter: boolean;
  14244. /**
  14245. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14246. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14247. */
  14248. billboardMode: number;
  14249. protected _isBillboardBased: boolean;
  14250. /**
  14251. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14252. */
  14253. isBillboardBased: boolean;
  14254. /**
  14255. * The scene the particle system belongs to.
  14256. */
  14257. protected _scene: Scene;
  14258. /**
  14259. * Local cache of defines for image processing.
  14260. */
  14261. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14262. /**
  14263. * Default configuration related to image processing available in the standard Material.
  14264. */
  14265. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14266. /**
  14267. * Gets the image processing configuration used either in this material.
  14268. */
  14269. /**
  14270. * Sets the Default image processing configuration used either in the this material.
  14271. *
  14272. * If sets to null, the scene one is in use.
  14273. */
  14274. imageProcessingConfiguration: ImageProcessingConfiguration;
  14275. /**
  14276. * Attaches a new image processing configuration to the Standard Material.
  14277. * @param configuration
  14278. */
  14279. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14280. /** @hidden */
  14281. protected _reset(): void;
  14282. /** @hidden */
  14283. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14284. /**
  14285. * Instantiates a particle system.
  14286. * 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.
  14287. * @param name The name of the particle system
  14288. */
  14289. constructor(name: string);
  14290. /**
  14291. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14292. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14293. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14294. * @returns the emitter
  14295. */
  14296. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14297. /**
  14298. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14299. * @param radius The radius of the hemisphere to emit from
  14300. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14301. * @returns the emitter
  14302. */
  14303. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14304. /**
  14305. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14306. * @param radius The radius of the sphere to emit from
  14307. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14308. * @returns the emitter
  14309. */
  14310. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14311. /**
  14312. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14313. * @param radius The radius of the sphere to emit from
  14314. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14315. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14316. * @returns the emitter
  14317. */
  14318. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14319. /**
  14320. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14321. * @param radius The radius of the emission cylinder
  14322. * @param height The height of the emission cylinder
  14323. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14324. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14325. * @returns the emitter
  14326. */
  14327. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14328. /**
  14329. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14330. * @param radius The radius of the cylinder to emit from
  14331. * @param height The height of the emission cylinder
  14332. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14333. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14334. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14335. * @returns the emitter
  14336. */
  14337. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14338. /**
  14339. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14340. * @param radius The radius of the cone to emit from
  14341. * @param angle The base angle of the cone
  14342. * @returns the emitter
  14343. */
  14344. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14345. /**
  14346. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14347. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14348. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14349. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14350. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14351. * @returns the emitter
  14352. */
  14353. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14354. }
  14355. }
  14356. declare module BABYLON {
  14357. /**
  14358. * Type of sub emitter
  14359. */
  14360. export enum SubEmitterType {
  14361. /**
  14362. * Attached to the particle over it's lifetime
  14363. */
  14364. ATTACHED = 0,
  14365. /**
  14366. * Created when the particle dies
  14367. */
  14368. END = 1
  14369. }
  14370. /**
  14371. * Sub emitter class used to emit particles from an existing particle
  14372. */
  14373. export class SubEmitter {
  14374. /**
  14375. * the particle system to be used by the sub emitter
  14376. */
  14377. particleSystem: ParticleSystem;
  14378. /**
  14379. * Type of the submitter (Default: END)
  14380. */
  14381. type: SubEmitterType;
  14382. /**
  14383. * 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)
  14384. * Note: This only is supported when using an emitter of type Mesh
  14385. */
  14386. inheritDirection: boolean;
  14387. /**
  14388. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14389. */
  14390. inheritedVelocityAmount: number;
  14391. /**
  14392. * Creates a sub emitter
  14393. * @param particleSystem the particle system to be used by the sub emitter
  14394. */
  14395. constructor(
  14396. /**
  14397. * the particle system to be used by the sub emitter
  14398. */
  14399. particleSystem: ParticleSystem);
  14400. /**
  14401. * Clones the sub emitter
  14402. * @returns the cloned sub emitter
  14403. */
  14404. clone(): SubEmitter;
  14405. /**
  14406. * Serialize current object to a JSON object
  14407. * @returns the serialized object
  14408. */
  14409. serialize(): any;
  14410. /** @hidden */ private static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14411. /**
  14412. * Creates a new SubEmitter from a serialized JSON version
  14413. * @param serializationObject defines the JSON object to read from
  14414. * @param scene defines the hosting scene
  14415. * @param rootUrl defines the rootUrl for data loading
  14416. * @returns a new SubEmitter
  14417. */
  14418. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14419. /** Release associated resources */
  14420. dispose(): void;
  14421. }
  14422. }
  14423. declare module BABYLON {
  14424. /** @hidden */
  14425. export var clipPlaneFragmentDeclaration: {
  14426. name: string;
  14427. shader: string;
  14428. };
  14429. }
  14430. declare module BABYLON {
  14431. /** @hidden */
  14432. export var imageProcessingDeclaration: {
  14433. name: string;
  14434. shader: string;
  14435. };
  14436. }
  14437. declare module BABYLON {
  14438. /** @hidden */
  14439. export var imageProcessingFunctions: {
  14440. name: string;
  14441. shader: string;
  14442. };
  14443. }
  14444. declare module BABYLON {
  14445. /** @hidden */
  14446. export var clipPlaneFragment: {
  14447. name: string;
  14448. shader: string;
  14449. };
  14450. }
  14451. declare module BABYLON {
  14452. /** @hidden */
  14453. export var particlesPixelShader: {
  14454. name: string;
  14455. shader: string;
  14456. };
  14457. }
  14458. declare module BABYLON {
  14459. /** @hidden */
  14460. export var clipPlaneVertexDeclaration: {
  14461. name: string;
  14462. shader: string;
  14463. };
  14464. }
  14465. declare module BABYLON {
  14466. /** @hidden */
  14467. export var clipPlaneVertex: {
  14468. name: string;
  14469. shader: string;
  14470. };
  14471. }
  14472. declare module BABYLON {
  14473. /** @hidden */
  14474. export var particlesVertexShader: {
  14475. name: string;
  14476. shader: string;
  14477. };
  14478. }
  14479. declare module BABYLON {
  14480. /**
  14481. * This represents a particle system in Babylon.
  14482. * 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.
  14483. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14484. * @example https://doc.babylonjs.com/babylon101/particles
  14485. */
  14486. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14487. /**
  14488. * Billboard mode will only apply to Y axis
  14489. */
  14490. static readonly BILLBOARDMODE_Y: number;
  14491. /**
  14492. * Billboard mode will apply to all axes
  14493. */
  14494. static readonly BILLBOARDMODE_ALL: number;
  14495. /**
  14496. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14497. */
  14498. static readonly BILLBOARDMODE_STRETCHED: number;
  14499. /**
  14500. * This function can be defined to provide custom update for active particles.
  14501. * This function will be called instead of regular update (age, position, color, etc.).
  14502. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14503. */
  14504. updateFunction: (particles: Particle[]) => void;
  14505. private _emitterWorldMatrix;
  14506. /**
  14507. * This function can be defined to specify initial direction for every new particle.
  14508. * It by default use the emitterType defined function
  14509. */
  14510. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14511. /**
  14512. * This function can be defined to specify initial position for every new particle.
  14513. * It by default use the emitterType defined function
  14514. */
  14515. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14516. /**
  14517. * @hidden
  14518. */ inheritedVelocityOffset: Vector3;
  14519. /**
  14520. * An event triggered when the system is disposed
  14521. */
  14522. onDisposeObservable: Observable<ParticleSystem>;
  14523. private _onDisposeObserver;
  14524. /**
  14525. * Sets a callback that will be triggered when the system is disposed
  14526. */
  14527. onDispose: () => void;
  14528. private _particles;
  14529. private _epsilon;
  14530. private _capacity;
  14531. private _stockParticles;
  14532. private _newPartsExcess;
  14533. private _vertexData;
  14534. private _vertexBuffer;
  14535. private _vertexBuffers;
  14536. private _spriteBuffer;
  14537. private _indexBuffer;
  14538. private _effect;
  14539. private _customEffect;
  14540. private _cachedDefines;
  14541. private _scaledColorStep;
  14542. private _colorDiff;
  14543. private _scaledDirection;
  14544. private _scaledGravity;
  14545. private _currentRenderId;
  14546. private _alive;
  14547. private _useInstancing;
  14548. private _started;
  14549. private _stopped;
  14550. private _actualFrame;
  14551. private _scaledUpdateSpeed;
  14552. private _vertexBufferSize;
  14553. /** @hidden */ currentEmitRateGradient: Nullable<FactorGradient>;
  14554. /** @hidden */ currentEmitRate1: number;
  14555. /** @hidden */ currentEmitRate2: number;
  14556. /** @hidden */ currentStartSizeGradient: Nullable<FactorGradient>;
  14557. /** @hidden */ currentStartSize1: number;
  14558. /** @hidden */ currentStartSize2: number;
  14559. private readonly _rawTextureWidth;
  14560. private _rampGradientsTexture;
  14561. private _useRampGradients;
  14562. /** Gets or sets a boolean indicating that ramp gradients must be used
  14563. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14564. */
  14565. useRampGradients: boolean;
  14566. /**
  14567. * 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.
  14568. * 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: [])
  14569. */
  14570. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14571. private _subEmitters;
  14572. /**
  14573. * @hidden
  14574. * If the particle systems emitter should be disposed when the particle system is disposed
  14575. */ disposeEmitterOnDispose: boolean;
  14576. /**
  14577. * The current active Sub-systems, this property is used by the root particle system only.
  14578. */
  14579. activeSubSystems: Array<ParticleSystem>;
  14580. private _rootParticleSystem;
  14581. /**
  14582. * Gets the current list of active particles
  14583. */
  14584. readonly particles: Particle[];
  14585. /**
  14586. * Returns the string "ParticleSystem"
  14587. * @returns a string containing the class name
  14588. */
  14589. getClassName(): string;
  14590. /**
  14591. * Instantiates a particle system.
  14592. * 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.
  14593. * @param name The name of the particle system
  14594. * @param capacity The max number of particles alive at the same time
  14595. * @param scene The scene the particle system belongs to
  14596. * @param customEffect a custom effect used to change the way particles are rendered by default
  14597. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14598. * @param epsilon Offset used to render the particles
  14599. */
  14600. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14601. private _addFactorGradient;
  14602. private _removeFactorGradient;
  14603. /**
  14604. * Adds a new life time gradient
  14605. * @param gradient defines the gradient to use (between 0 and 1)
  14606. * @param factor defines the life time factor to affect to the specified gradient
  14607. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14608. * @returns the current particle system
  14609. */
  14610. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14611. /**
  14612. * Remove a specific life time gradient
  14613. * @param gradient defines the gradient to remove
  14614. * @returns the current particle system
  14615. */
  14616. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14617. /**
  14618. * Adds a new size gradient
  14619. * @param gradient defines the gradient to use (between 0 and 1)
  14620. * @param factor defines the size factor to affect to the specified gradient
  14621. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14622. * @returns the current particle system
  14623. */
  14624. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14625. /**
  14626. * Remove a specific size gradient
  14627. * @param gradient defines the gradient to remove
  14628. * @returns the current particle system
  14629. */
  14630. removeSizeGradient(gradient: number): IParticleSystem;
  14631. /**
  14632. * Adds a new color remap gradient
  14633. * @param gradient defines the gradient to use (between 0 and 1)
  14634. * @param min defines the color remap minimal range
  14635. * @param max defines the color remap maximal range
  14636. * @returns the current particle system
  14637. */
  14638. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14639. /**
  14640. * Remove a specific color remap gradient
  14641. * @param gradient defines the gradient to remove
  14642. * @returns the current particle system
  14643. */
  14644. removeColorRemapGradient(gradient: number): IParticleSystem;
  14645. /**
  14646. * Adds a new alpha remap gradient
  14647. * @param gradient defines the gradient to use (between 0 and 1)
  14648. * @param min defines the alpha remap minimal range
  14649. * @param max defines the alpha remap maximal range
  14650. * @returns the current particle system
  14651. */
  14652. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14653. /**
  14654. * Remove a specific alpha remap gradient
  14655. * @param gradient defines the gradient to remove
  14656. * @returns the current particle system
  14657. */
  14658. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14659. /**
  14660. * Adds a new angular speed gradient
  14661. * @param gradient defines the gradient to use (between 0 and 1)
  14662. * @param factor defines the angular speed to affect to the specified gradient
  14663. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14664. * @returns the current particle system
  14665. */
  14666. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14667. /**
  14668. * Remove a specific angular speed gradient
  14669. * @param gradient defines the gradient to remove
  14670. * @returns the current particle system
  14671. */
  14672. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14673. /**
  14674. * Adds a new velocity gradient
  14675. * @param gradient defines the gradient to use (between 0 and 1)
  14676. * @param factor defines the velocity to affect to the specified gradient
  14677. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14678. * @returns the current particle system
  14679. */
  14680. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14681. /**
  14682. * Remove a specific velocity gradient
  14683. * @param gradient defines the gradient to remove
  14684. * @returns the current particle system
  14685. */
  14686. removeVelocityGradient(gradient: number): IParticleSystem;
  14687. /**
  14688. * Adds a new limit velocity gradient
  14689. * @param gradient defines the gradient to use (between 0 and 1)
  14690. * @param factor defines the limit velocity value to affect to the specified gradient
  14691. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14692. * @returns the current particle system
  14693. */
  14694. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14695. /**
  14696. * Remove a specific limit velocity gradient
  14697. * @param gradient defines the gradient to remove
  14698. * @returns the current particle system
  14699. */
  14700. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14701. /**
  14702. * Adds a new drag gradient
  14703. * @param gradient defines the gradient to use (between 0 and 1)
  14704. * @param factor defines the drag value to affect to the specified gradient
  14705. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14706. * @returns the current particle system
  14707. */
  14708. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14709. /**
  14710. * Remove a specific drag gradient
  14711. * @param gradient defines the gradient to remove
  14712. * @returns the current particle system
  14713. */
  14714. removeDragGradient(gradient: number): IParticleSystem;
  14715. /**
  14716. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14717. * @param gradient defines the gradient to use (between 0 and 1)
  14718. * @param factor defines the emit rate value to affect to the specified gradient
  14719. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14720. * @returns the current particle system
  14721. */
  14722. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14723. /**
  14724. * Remove a specific emit rate gradient
  14725. * @param gradient defines the gradient to remove
  14726. * @returns the current particle system
  14727. */
  14728. removeEmitRateGradient(gradient: number): IParticleSystem;
  14729. /**
  14730. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14731. * @param gradient defines the gradient to use (between 0 and 1)
  14732. * @param factor defines the start size value to affect to the specified gradient
  14733. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14734. * @returns the current particle system
  14735. */
  14736. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14737. /**
  14738. * Remove a specific start size gradient
  14739. * @param gradient defines the gradient to remove
  14740. * @returns the current particle system
  14741. */
  14742. removeStartSizeGradient(gradient: number): IParticleSystem;
  14743. private _createRampGradientTexture;
  14744. /**
  14745. * Gets the current list of ramp gradients.
  14746. * You must use addRampGradient and removeRampGradient to udpate this list
  14747. * @returns the list of ramp gradients
  14748. */
  14749. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14750. /**
  14751. * Adds a new ramp gradient used to remap particle colors
  14752. * @param gradient defines the gradient to use (between 0 and 1)
  14753. * @param color defines the color to affect to the specified gradient
  14754. * @returns the current particle system
  14755. */
  14756. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14757. /**
  14758. * Remove a specific ramp gradient
  14759. * @param gradient defines the gradient to remove
  14760. * @returns the current particle system
  14761. */
  14762. removeRampGradient(gradient: number): ParticleSystem;
  14763. /**
  14764. * Adds a new color gradient
  14765. * @param gradient defines the gradient to use (between 0 and 1)
  14766. * @param color1 defines the color to affect to the specified gradient
  14767. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14768. * @returns this particle system
  14769. */
  14770. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14771. /**
  14772. * Remove a specific color gradient
  14773. * @param gradient defines the gradient to remove
  14774. * @returns this particle system
  14775. */
  14776. removeColorGradient(gradient: number): IParticleSystem;
  14777. private _fetchR;
  14778. protected _reset(): void;
  14779. private _resetEffect;
  14780. private _createVertexBuffers;
  14781. private _createIndexBuffer;
  14782. /**
  14783. * Gets the maximum number of particles active at the same time.
  14784. * @returns The max number of active particles.
  14785. */
  14786. getCapacity(): number;
  14787. /**
  14788. * Gets whether there are still active particles in the system.
  14789. * @returns True if it is alive, otherwise false.
  14790. */
  14791. isAlive(): boolean;
  14792. /**
  14793. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14794. * @returns True if it has been started, otherwise false.
  14795. */
  14796. isStarted(): boolean;
  14797. private _prepareSubEmitterInternalArray;
  14798. /**
  14799. * Starts the particle system and begins to emit
  14800. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  14801. */
  14802. start(delay?: number): void;
  14803. /**
  14804. * Stops the particle system.
  14805. * @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.
  14806. */
  14807. stop(stopSubEmitters?: boolean): void;
  14808. /**
  14809. * Remove all active particles
  14810. */
  14811. reset(): void;
  14812. /**
  14813. * @hidden (for internal use only)
  14814. */ appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  14815. /**
  14816. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  14817. * Its lifetime will start back at 0.
  14818. */
  14819. recycleParticle: (particle: Particle) => void;
  14820. private _stopSubEmitters;
  14821. private _createParticle;
  14822. private _removeFromRoot;
  14823. private _emitFromParticle;
  14824. private _update;
  14825. /** @hidden */ private static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  14826. /** @hidden */ private static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  14827. /** @hidden */
  14828. private _getEffect;
  14829. /**
  14830. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  14831. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  14832. */
  14833. animate(preWarmOnly?: boolean): void;
  14834. private _appendParticleVertices;
  14835. /**
  14836. * Rebuilds the particle system.
  14837. */
  14838. rebuild(): void;
  14839. /**
  14840. * Is this system ready to be used/rendered
  14841. * @return true if the system is ready
  14842. */
  14843. isReady(): boolean;
  14844. private _render;
  14845. /**
  14846. * Renders the particle system in its current state.
  14847. * @returns the current number of particles
  14848. */
  14849. render(): number;
  14850. /**
  14851. * Disposes the particle system and free the associated resources
  14852. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14853. */
  14854. dispose(disposeTexture?: boolean): void;
  14855. /**
  14856. * Clones the particle system.
  14857. * @param name The name of the cloned object
  14858. * @param newEmitter The new emitter to use
  14859. * @returns the cloned particle system
  14860. */
  14861. clone(name: string, newEmitter: any): ParticleSystem;
  14862. /**
  14863. * Serializes the particle system to a JSON object.
  14864. * @returns the JSON object
  14865. */
  14866. serialize(): any;
  14867. /** @hidden */ private static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  14868. /** @hidden */ private static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  14869. /**
  14870. * Parses a JSON object to create a particle system.
  14871. * @param parsedParticleSystem The JSON object to parse
  14872. * @param scene The scene to create the particle system in
  14873. * @param rootUrl The root url to use to load external dependencies like texture
  14874. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  14875. * @returns the Parsed particle system
  14876. */
  14877. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  14878. }
  14879. }
  14880. declare module BABYLON {
  14881. /**
  14882. * A particle represents one of the element emitted by a particle system.
  14883. * This is mainly define by its coordinates, direction, velocity and age.
  14884. */
  14885. export class Particle {
  14886. /**
  14887. * The particle system the particle belongs to.
  14888. */
  14889. particleSystem: ParticleSystem;
  14890. private static _Count;
  14891. /**
  14892. * Unique ID of the particle
  14893. */
  14894. id: number;
  14895. /**
  14896. * The world position of the particle in the scene.
  14897. */
  14898. position: Vector3;
  14899. /**
  14900. * The world direction of the particle in the scene.
  14901. */
  14902. direction: Vector3;
  14903. /**
  14904. * The color of the particle.
  14905. */
  14906. color: Color4;
  14907. /**
  14908. * The color change of the particle per step.
  14909. */
  14910. colorStep: Color4;
  14911. /**
  14912. * Defines how long will the life of the particle be.
  14913. */
  14914. lifeTime: number;
  14915. /**
  14916. * The current age of the particle.
  14917. */
  14918. age: number;
  14919. /**
  14920. * The current size of the particle.
  14921. */
  14922. size: number;
  14923. /**
  14924. * The current scale of the particle.
  14925. */
  14926. scale: Vector2;
  14927. /**
  14928. * The current angle of the particle.
  14929. */
  14930. angle: number;
  14931. /**
  14932. * Defines how fast is the angle changing.
  14933. */
  14934. angularSpeed: number;
  14935. /**
  14936. * Defines the cell index used by the particle to be rendered from a sprite.
  14937. */
  14938. cellIndex: number;
  14939. /**
  14940. * The information required to support color remapping
  14941. */
  14942. remapData: Vector4;
  14943. /** @hidden */ randomCellOffset?: number;
  14944. /** @hidden */ initialDirection: Nullable<Vector3>;
  14945. /** @hidden */ attachedSubEmitters: Nullable<Array<SubEmitter>>;
  14946. /** @hidden */ initialStartSpriteCellID: number;
  14947. /** @hidden */ initialEndSpriteCellID: number;
  14948. /** @hidden */ currentColorGradient: Nullable<ColorGradient>;
  14949. /** @hidden */ currentColor1: Color4;
  14950. /** @hidden */ currentColor2: Color4;
  14951. /** @hidden */ currentSizeGradient: Nullable<FactorGradient>;
  14952. /** @hidden */ currentSize1: number;
  14953. /** @hidden */ currentSize2: number;
  14954. /** @hidden */ currentAngularSpeedGradient: Nullable<FactorGradient>;
  14955. /** @hidden */ currentAngularSpeed1: number;
  14956. /** @hidden */ currentAngularSpeed2: number;
  14957. /** @hidden */ currentVelocityGradient: Nullable<FactorGradient>;
  14958. /** @hidden */ currentVelocity1: number;
  14959. /** @hidden */ currentVelocity2: number;
  14960. /** @hidden */ currentLimitVelocityGradient: Nullable<FactorGradient>;
  14961. /** @hidden */ currentLimitVelocity1: number;
  14962. /** @hidden */ currentLimitVelocity2: number;
  14963. /** @hidden */ currentDragGradient: Nullable<FactorGradient>;
  14964. /** @hidden */ currentDrag1: number;
  14965. /** @hidden */ currentDrag2: number;
  14966. /** @hidden */ randomNoiseCoordinates1: Vector3;
  14967. /** @hidden */ randomNoiseCoordinates2: Vector3;
  14968. /**
  14969. * Creates a new instance Particle
  14970. * @param particleSystem the particle system the particle belongs to
  14971. */
  14972. constructor(
  14973. /**
  14974. * The particle system the particle belongs to.
  14975. */
  14976. particleSystem: ParticleSystem);
  14977. private updateCellInfoFromSystem;
  14978. /**
  14979. * Defines how the sprite cell index is updated for the particle
  14980. */
  14981. updateCellIndex(): void;
  14982. /** @hidden */ inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  14983. /** @hidden */ inheritParticleInfoToSubEmitters(): void;
  14984. /** @hidden */ reset(): void;
  14985. /**
  14986. * Copy the properties of particle to another one.
  14987. * @param other the particle to copy the information to.
  14988. */
  14989. copyTo(other: Particle): void;
  14990. }
  14991. }
  14992. declare module BABYLON {
  14993. /**
  14994. * Particle emitter represents a volume emitting particles.
  14995. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  14996. */
  14997. export interface IParticleEmitterType {
  14998. /**
  14999. * Called by the particle System when the direction is computed for the created particle.
  15000. * @param worldMatrix is the world matrix of the particle system
  15001. * @param directionToUpdate is the direction vector to update with the result
  15002. * @param particle is the particle we are computed the direction for
  15003. */
  15004. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15005. /**
  15006. * Called by the particle System when the position is computed for the created particle.
  15007. * @param worldMatrix is the world matrix of the particle system
  15008. * @param positionToUpdate is the position vector to update with the result
  15009. * @param particle is the particle we are computed the position for
  15010. */
  15011. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15012. /**
  15013. * Clones the current emitter and returns a copy of it
  15014. * @returns the new emitter
  15015. */
  15016. clone(): IParticleEmitterType;
  15017. /**
  15018. * Called by the GPUParticleSystem to setup the update shader
  15019. * @param effect defines the update shader
  15020. */
  15021. applyToShader(effect: Effect): void;
  15022. /**
  15023. * Returns a string to use to update the GPU particles update shader
  15024. * @returns the effect defines string
  15025. */
  15026. getEffectDefines(): string;
  15027. /**
  15028. * Returns a string representing the class name
  15029. * @returns a string containing the class name
  15030. */
  15031. getClassName(): string;
  15032. /**
  15033. * Serializes the particle system to a JSON object.
  15034. * @returns the JSON object
  15035. */
  15036. serialize(): any;
  15037. /**
  15038. * Parse properties from a JSON object
  15039. * @param serializationObject defines the JSON object
  15040. */
  15041. parse(serializationObject: any): void;
  15042. }
  15043. }
  15044. declare module BABYLON {
  15045. /**
  15046. * Particle emitter emitting particles from the inside of a box.
  15047. * It emits the particles randomly between 2 given directions.
  15048. */
  15049. export class BoxParticleEmitter implements IParticleEmitterType {
  15050. /**
  15051. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15052. */
  15053. direction1: Vector3;
  15054. /**
  15055. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15056. */
  15057. direction2: Vector3;
  15058. /**
  15059. * 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.
  15060. */
  15061. minEmitBox: Vector3;
  15062. /**
  15063. * 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.
  15064. */
  15065. maxEmitBox: Vector3;
  15066. /**
  15067. * Creates a new instance BoxParticleEmitter
  15068. */
  15069. constructor();
  15070. /**
  15071. * Called by the particle System when the direction is computed for the created particle.
  15072. * @param worldMatrix is the world matrix of the particle system
  15073. * @param directionToUpdate is the direction vector to update with the result
  15074. * @param particle is the particle we are computed the direction for
  15075. */
  15076. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15077. /**
  15078. * Called by the particle System when the position is computed for the created particle.
  15079. * @param worldMatrix is the world matrix of the particle system
  15080. * @param positionToUpdate is the position vector to update with the result
  15081. * @param particle is the particle we are computed the position for
  15082. */
  15083. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15084. /**
  15085. * Clones the current emitter and returns a copy of it
  15086. * @returns the new emitter
  15087. */
  15088. clone(): BoxParticleEmitter;
  15089. /**
  15090. * Called by the GPUParticleSystem to setup the update shader
  15091. * @param effect defines the update shader
  15092. */
  15093. applyToShader(effect: Effect): void;
  15094. /**
  15095. * Returns a string to use to update the GPU particles update shader
  15096. * @returns a string containng the defines string
  15097. */
  15098. getEffectDefines(): string;
  15099. /**
  15100. * Returns the string "BoxParticleEmitter"
  15101. * @returns a string containing the class name
  15102. */
  15103. getClassName(): string;
  15104. /**
  15105. * Serializes the particle system to a JSON object.
  15106. * @returns the JSON object
  15107. */
  15108. serialize(): any;
  15109. /**
  15110. * Parse properties from a JSON object
  15111. * @param serializationObject defines the JSON object
  15112. */
  15113. parse(serializationObject: any): void;
  15114. }
  15115. }
  15116. declare module BABYLON {
  15117. /**
  15118. * Particle emitter emitting particles from the inside of a cone.
  15119. * It emits the particles alongside the cone volume from the base to the particle.
  15120. * The emission direction might be randomized.
  15121. */
  15122. export class ConeParticleEmitter implements IParticleEmitterType {
  15123. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15124. directionRandomizer: number;
  15125. private _radius;
  15126. private _angle;
  15127. private _height;
  15128. /**
  15129. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15130. */
  15131. radiusRange: number;
  15132. /**
  15133. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15134. */
  15135. heightRange: number;
  15136. /**
  15137. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15138. */
  15139. emitFromSpawnPointOnly: boolean;
  15140. /**
  15141. * Gets or sets the radius of the emission cone
  15142. */
  15143. radius: number;
  15144. /**
  15145. * Gets or sets the angle of the emission cone
  15146. */
  15147. angle: number;
  15148. private _buildHeight;
  15149. /**
  15150. * Creates a new instance ConeParticleEmitter
  15151. * @param radius the radius of the emission cone (1 by default)
  15152. * @param angle the cone base angle (PI by default)
  15153. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15154. */
  15155. constructor(radius?: number, angle?: number,
  15156. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15157. directionRandomizer?: number);
  15158. /**
  15159. * Called by the particle System when the direction is computed for the created particle.
  15160. * @param worldMatrix is the world matrix of the particle system
  15161. * @param directionToUpdate is the direction vector to update with the result
  15162. * @param particle is the particle we are computed the direction for
  15163. */
  15164. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15165. /**
  15166. * Called by the particle System when the position is computed for the created particle.
  15167. * @param worldMatrix is the world matrix of the particle system
  15168. * @param positionToUpdate is the position vector to update with the result
  15169. * @param particle is the particle we are computed the position for
  15170. */
  15171. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15172. /**
  15173. * Clones the current emitter and returns a copy of it
  15174. * @returns the new emitter
  15175. */
  15176. clone(): ConeParticleEmitter;
  15177. /**
  15178. * Called by the GPUParticleSystem to setup the update shader
  15179. * @param effect defines the update shader
  15180. */
  15181. applyToShader(effect: Effect): void;
  15182. /**
  15183. * Returns a string to use to update the GPU particles update shader
  15184. * @returns a string containng the defines string
  15185. */
  15186. getEffectDefines(): string;
  15187. /**
  15188. * Returns the string "ConeParticleEmitter"
  15189. * @returns a string containing the class name
  15190. */
  15191. getClassName(): string;
  15192. /**
  15193. * Serializes the particle system to a JSON object.
  15194. * @returns the JSON object
  15195. */
  15196. serialize(): any;
  15197. /**
  15198. * Parse properties from a JSON object
  15199. * @param serializationObject defines the JSON object
  15200. */
  15201. parse(serializationObject: any): void;
  15202. }
  15203. }
  15204. declare module BABYLON {
  15205. /**
  15206. * Particle emitter emitting particles from the inside of a cylinder.
  15207. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15208. */
  15209. export class CylinderParticleEmitter implements IParticleEmitterType {
  15210. /**
  15211. * The radius of the emission cylinder.
  15212. */
  15213. radius: number;
  15214. /**
  15215. * The height of the emission cylinder.
  15216. */
  15217. height: number;
  15218. /**
  15219. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15220. */
  15221. radiusRange: number;
  15222. /**
  15223. * How much to randomize the particle direction [0-1].
  15224. */
  15225. directionRandomizer: number;
  15226. /**
  15227. * Creates a new instance CylinderParticleEmitter
  15228. * @param radius the radius of the emission cylinder (1 by default)
  15229. * @param height the height of the emission cylinder (1 by default)
  15230. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15231. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15232. */
  15233. constructor(
  15234. /**
  15235. * The radius of the emission cylinder.
  15236. */
  15237. radius?: number,
  15238. /**
  15239. * The height of the emission cylinder.
  15240. */
  15241. height?: number,
  15242. /**
  15243. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15244. */
  15245. radiusRange?: number,
  15246. /**
  15247. * How much to randomize the particle direction [0-1].
  15248. */
  15249. directionRandomizer?: number);
  15250. /**
  15251. * Called by the particle System when the direction is computed for the created particle.
  15252. * @param worldMatrix is the world matrix of the particle system
  15253. * @param directionToUpdate is the direction vector to update with the result
  15254. * @param particle is the particle we are computed the direction for
  15255. */
  15256. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15257. /**
  15258. * Called by the particle System when the position is computed for the created particle.
  15259. * @param worldMatrix is the world matrix of the particle system
  15260. * @param positionToUpdate is the position vector to update with the result
  15261. * @param particle is the particle we are computed the position for
  15262. */
  15263. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15264. /**
  15265. * Clones the current emitter and returns a copy of it
  15266. * @returns the new emitter
  15267. */
  15268. clone(): CylinderParticleEmitter;
  15269. /**
  15270. * Called by the GPUParticleSystem to setup the update shader
  15271. * @param effect defines the update shader
  15272. */
  15273. applyToShader(effect: Effect): void;
  15274. /**
  15275. * Returns a string to use to update the GPU particles update shader
  15276. * @returns a string containng the defines string
  15277. */
  15278. getEffectDefines(): string;
  15279. /**
  15280. * Returns the string "CylinderParticleEmitter"
  15281. * @returns a string containing the class name
  15282. */
  15283. getClassName(): string;
  15284. /**
  15285. * Serializes the particle system to a JSON object.
  15286. * @returns the JSON object
  15287. */
  15288. serialize(): any;
  15289. /**
  15290. * Parse properties from a JSON object
  15291. * @param serializationObject defines the JSON object
  15292. */
  15293. parse(serializationObject: any): void;
  15294. }
  15295. /**
  15296. * Particle emitter emitting particles from the inside of a cylinder.
  15297. * It emits the particles randomly between two vectors.
  15298. */
  15299. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15300. /**
  15301. * The min limit of the emission direction.
  15302. */
  15303. direction1: Vector3;
  15304. /**
  15305. * The max limit of the emission direction.
  15306. */
  15307. direction2: Vector3;
  15308. /**
  15309. * Creates a new instance CylinderDirectedParticleEmitter
  15310. * @param radius the radius of the emission cylinder (1 by default)
  15311. * @param height the height of the emission cylinder (1 by default)
  15312. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15313. * @param direction1 the min limit of the emission direction (up vector by default)
  15314. * @param direction2 the max limit of the emission direction (up vector by default)
  15315. */
  15316. constructor(radius?: number, height?: number, radiusRange?: number,
  15317. /**
  15318. * The min limit of the emission direction.
  15319. */
  15320. direction1?: Vector3,
  15321. /**
  15322. * The max limit of the emission direction.
  15323. */
  15324. direction2?: Vector3);
  15325. /**
  15326. * Called by the particle System when the direction is computed for the created particle.
  15327. * @param worldMatrix is the world matrix of the particle system
  15328. * @param directionToUpdate is the direction vector to update with the result
  15329. * @param particle is the particle we are computed the direction for
  15330. */
  15331. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15332. /**
  15333. * Clones the current emitter and returns a copy of it
  15334. * @returns the new emitter
  15335. */
  15336. clone(): CylinderDirectedParticleEmitter;
  15337. /**
  15338. * Called by the GPUParticleSystem to setup the update shader
  15339. * @param effect defines the update shader
  15340. */
  15341. applyToShader(effect: Effect): void;
  15342. /**
  15343. * Returns a string to use to update the GPU particles update shader
  15344. * @returns a string containng the defines string
  15345. */
  15346. getEffectDefines(): string;
  15347. /**
  15348. * Returns the string "CylinderDirectedParticleEmitter"
  15349. * @returns a string containing the class name
  15350. */
  15351. getClassName(): string;
  15352. /**
  15353. * Serializes the particle system to a JSON object.
  15354. * @returns the JSON object
  15355. */
  15356. serialize(): any;
  15357. /**
  15358. * Parse properties from a JSON object
  15359. * @param serializationObject defines the JSON object
  15360. */
  15361. parse(serializationObject: any): void;
  15362. }
  15363. }
  15364. declare module BABYLON {
  15365. /**
  15366. * Particle emitter emitting particles from the inside of a hemisphere.
  15367. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15368. */
  15369. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15370. /**
  15371. * The radius of the emission hemisphere.
  15372. */
  15373. radius: number;
  15374. /**
  15375. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15376. */
  15377. radiusRange: number;
  15378. /**
  15379. * How much to randomize the particle direction [0-1].
  15380. */
  15381. directionRandomizer: number;
  15382. /**
  15383. * Creates a new instance HemisphericParticleEmitter
  15384. * @param radius the radius of the emission hemisphere (1 by default)
  15385. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15386. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15387. */
  15388. constructor(
  15389. /**
  15390. * The radius of the emission hemisphere.
  15391. */
  15392. radius?: number,
  15393. /**
  15394. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15395. */
  15396. radiusRange?: number,
  15397. /**
  15398. * How much to randomize the particle direction [0-1].
  15399. */
  15400. directionRandomizer?: number);
  15401. /**
  15402. * Called by the particle System when the direction is computed for the created particle.
  15403. * @param worldMatrix is the world matrix of the particle system
  15404. * @param directionToUpdate is the direction vector to update with the result
  15405. * @param particle is the particle we are computed the direction for
  15406. */
  15407. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15408. /**
  15409. * Called by the particle System when the position is computed for the created particle.
  15410. * @param worldMatrix is the world matrix of the particle system
  15411. * @param positionToUpdate is the position vector to update with the result
  15412. * @param particle is the particle we are computed the position for
  15413. */
  15414. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15415. /**
  15416. * Clones the current emitter and returns a copy of it
  15417. * @returns the new emitter
  15418. */
  15419. clone(): HemisphericParticleEmitter;
  15420. /**
  15421. * Called by the GPUParticleSystem to setup the update shader
  15422. * @param effect defines the update shader
  15423. */
  15424. applyToShader(effect: Effect): void;
  15425. /**
  15426. * Returns a string to use to update the GPU particles update shader
  15427. * @returns a string containng the defines string
  15428. */
  15429. getEffectDefines(): string;
  15430. /**
  15431. * Returns the string "HemisphericParticleEmitter"
  15432. * @returns a string containing the class name
  15433. */
  15434. getClassName(): string;
  15435. /**
  15436. * Serializes the particle system to a JSON object.
  15437. * @returns the JSON object
  15438. */
  15439. serialize(): any;
  15440. /**
  15441. * Parse properties from a JSON object
  15442. * @param serializationObject defines the JSON object
  15443. */
  15444. parse(serializationObject: any): void;
  15445. }
  15446. }
  15447. declare module BABYLON {
  15448. /**
  15449. * Particle emitter emitting particles from a point.
  15450. * It emits the particles randomly between 2 given directions.
  15451. */
  15452. export class PointParticleEmitter implements IParticleEmitterType {
  15453. /**
  15454. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15455. */
  15456. direction1: Vector3;
  15457. /**
  15458. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15459. */
  15460. direction2: Vector3;
  15461. /**
  15462. * Creates a new instance PointParticleEmitter
  15463. */
  15464. constructor();
  15465. /**
  15466. * Called by the particle System when the direction is computed for the created particle.
  15467. * @param worldMatrix is the world matrix of the particle system
  15468. * @param directionToUpdate is the direction vector to update with the result
  15469. * @param particle is the particle we are computed the direction for
  15470. */
  15471. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15472. /**
  15473. * Called by the particle System when the position is computed for the created particle.
  15474. * @param worldMatrix is the world matrix of the particle system
  15475. * @param positionToUpdate is the position vector to update with the result
  15476. * @param particle is the particle we are computed the position for
  15477. */
  15478. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15479. /**
  15480. * Clones the current emitter and returns a copy of it
  15481. * @returns the new emitter
  15482. */
  15483. clone(): PointParticleEmitter;
  15484. /**
  15485. * Called by the GPUParticleSystem to setup the update shader
  15486. * @param effect defines the update shader
  15487. */
  15488. applyToShader(effect: Effect): void;
  15489. /**
  15490. * Returns a string to use to update the GPU particles update shader
  15491. * @returns a string containng the defines string
  15492. */
  15493. getEffectDefines(): string;
  15494. /**
  15495. * Returns the string "PointParticleEmitter"
  15496. * @returns a string containing the class name
  15497. */
  15498. getClassName(): string;
  15499. /**
  15500. * Serializes the particle system to a JSON object.
  15501. * @returns the JSON object
  15502. */
  15503. serialize(): any;
  15504. /**
  15505. * Parse properties from a JSON object
  15506. * @param serializationObject defines the JSON object
  15507. */
  15508. parse(serializationObject: any): void;
  15509. }
  15510. }
  15511. declare module BABYLON {
  15512. /**
  15513. * Particle emitter emitting particles from the inside of a sphere.
  15514. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15515. */
  15516. export class SphereParticleEmitter implements IParticleEmitterType {
  15517. /**
  15518. * The radius of the emission sphere.
  15519. */
  15520. radius: number;
  15521. /**
  15522. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15523. */
  15524. radiusRange: number;
  15525. /**
  15526. * How much to randomize the particle direction [0-1].
  15527. */
  15528. directionRandomizer: number;
  15529. /**
  15530. * Creates a new instance SphereParticleEmitter
  15531. * @param radius the radius of the emission sphere (1 by default)
  15532. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15533. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15534. */
  15535. constructor(
  15536. /**
  15537. * The radius of the emission sphere.
  15538. */
  15539. radius?: number,
  15540. /**
  15541. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15542. */
  15543. radiusRange?: number,
  15544. /**
  15545. * How much to randomize the particle direction [0-1].
  15546. */
  15547. directionRandomizer?: number);
  15548. /**
  15549. * Called by the particle System when the direction is computed for the created particle.
  15550. * @param worldMatrix is the world matrix of the particle system
  15551. * @param directionToUpdate is the direction vector to update with the result
  15552. * @param particle is the particle we are computed the direction for
  15553. */
  15554. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15555. /**
  15556. * Called by the particle System when the position is computed for the created particle.
  15557. * @param worldMatrix is the world matrix of the particle system
  15558. * @param positionToUpdate is the position vector to update with the result
  15559. * @param particle is the particle we are computed the position for
  15560. */
  15561. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15562. /**
  15563. * Clones the current emitter and returns a copy of it
  15564. * @returns the new emitter
  15565. */
  15566. clone(): SphereParticleEmitter;
  15567. /**
  15568. * Called by the GPUParticleSystem to setup the update shader
  15569. * @param effect defines the update shader
  15570. */
  15571. applyToShader(effect: Effect): void;
  15572. /**
  15573. * Returns a string to use to update the GPU particles update shader
  15574. * @returns a string containng the defines string
  15575. */
  15576. getEffectDefines(): string;
  15577. /**
  15578. * Returns the string "SphereParticleEmitter"
  15579. * @returns a string containing the class name
  15580. */
  15581. getClassName(): string;
  15582. /**
  15583. * Serializes the particle system to a JSON object.
  15584. * @returns the JSON object
  15585. */
  15586. serialize(): any;
  15587. /**
  15588. * Parse properties from a JSON object
  15589. * @param serializationObject defines the JSON object
  15590. */
  15591. parse(serializationObject: any): void;
  15592. }
  15593. /**
  15594. * Particle emitter emitting particles from the inside of a sphere.
  15595. * It emits the particles randomly between two vectors.
  15596. */
  15597. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15598. /**
  15599. * The min limit of the emission direction.
  15600. */
  15601. direction1: Vector3;
  15602. /**
  15603. * The max limit of the emission direction.
  15604. */
  15605. direction2: Vector3;
  15606. /**
  15607. * Creates a new instance SphereDirectedParticleEmitter
  15608. * @param radius the radius of the emission sphere (1 by default)
  15609. * @param direction1 the min limit of the emission direction (up vector by default)
  15610. * @param direction2 the max limit of the emission direction (up vector by default)
  15611. */
  15612. constructor(radius?: number,
  15613. /**
  15614. * The min limit of the emission direction.
  15615. */
  15616. direction1?: Vector3,
  15617. /**
  15618. * The max limit of the emission direction.
  15619. */
  15620. direction2?: Vector3);
  15621. /**
  15622. * Called by the particle System when the direction is computed for the created particle.
  15623. * @param worldMatrix is the world matrix of the particle system
  15624. * @param directionToUpdate is the direction vector to update with the result
  15625. * @param particle is the particle we are computed the direction for
  15626. */
  15627. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15628. /**
  15629. * Clones the current emitter and returns a copy of it
  15630. * @returns the new emitter
  15631. */
  15632. clone(): SphereDirectedParticleEmitter;
  15633. /**
  15634. * Called by the GPUParticleSystem to setup the update shader
  15635. * @param effect defines the update shader
  15636. */
  15637. applyToShader(effect: Effect): void;
  15638. /**
  15639. * Returns a string to use to update the GPU particles update shader
  15640. * @returns a string containng the defines string
  15641. */
  15642. getEffectDefines(): string;
  15643. /**
  15644. * Returns the string "SphereDirectedParticleEmitter"
  15645. * @returns a string containing the class name
  15646. */
  15647. getClassName(): string;
  15648. /**
  15649. * Serializes the particle system to a JSON object.
  15650. * @returns the JSON object
  15651. */
  15652. serialize(): any;
  15653. /**
  15654. * Parse properties from a JSON object
  15655. * @param serializationObject defines the JSON object
  15656. */
  15657. parse(serializationObject: any): void;
  15658. }
  15659. }
  15660. declare module BABYLON {
  15661. /**
  15662. * Interface representing a particle system in Babylon.js.
  15663. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15664. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15665. */
  15666. export interface IParticleSystem {
  15667. /**
  15668. * List of animations used by the particle system.
  15669. */
  15670. animations: Animation[];
  15671. /**
  15672. * The id of the Particle system.
  15673. */
  15674. id: string;
  15675. /**
  15676. * The name of the Particle system.
  15677. */
  15678. name: string;
  15679. /**
  15680. * The emitter represents the Mesh or position we are attaching the particle system to.
  15681. */
  15682. emitter: Nullable<AbstractMesh | Vector3>;
  15683. /**
  15684. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15685. */
  15686. isBillboardBased: boolean;
  15687. /**
  15688. * The rendering group used by the Particle system to chose when to render.
  15689. */
  15690. renderingGroupId: number;
  15691. /**
  15692. * The layer mask we are rendering the particles through.
  15693. */
  15694. layerMask: number;
  15695. /**
  15696. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15697. */
  15698. updateSpeed: number;
  15699. /**
  15700. * The amount of time the particle system is running (depends of the overall update speed).
  15701. */
  15702. targetStopDuration: number;
  15703. /**
  15704. * The texture used to render each particle. (this can be a spritesheet)
  15705. */
  15706. particleTexture: Nullable<Texture>;
  15707. /**
  15708. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  15709. */
  15710. blendMode: number;
  15711. /**
  15712. * Minimum life time of emitting particles.
  15713. */
  15714. minLifeTime: number;
  15715. /**
  15716. * Maximum life time of emitting particles.
  15717. */
  15718. maxLifeTime: number;
  15719. /**
  15720. * Minimum Size of emitting particles.
  15721. */
  15722. minSize: number;
  15723. /**
  15724. * Maximum Size of emitting particles.
  15725. */
  15726. maxSize: number;
  15727. /**
  15728. * Minimum scale of emitting particles on X axis.
  15729. */
  15730. minScaleX: number;
  15731. /**
  15732. * Maximum scale of emitting particles on X axis.
  15733. */
  15734. maxScaleX: number;
  15735. /**
  15736. * Minimum scale of emitting particles on Y axis.
  15737. */
  15738. minScaleY: number;
  15739. /**
  15740. * Maximum scale of emitting particles on Y axis.
  15741. */
  15742. maxScaleY: number;
  15743. /**
  15744. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15745. */
  15746. color1: Color4;
  15747. /**
  15748. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15749. */
  15750. color2: Color4;
  15751. /**
  15752. * Color the particle will have at the end of its lifetime.
  15753. */
  15754. colorDead: Color4;
  15755. /**
  15756. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  15757. */
  15758. emitRate: number;
  15759. /**
  15760. * You can use gravity if you want to give an orientation to your particles.
  15761. */
  15762. gravity: Vector3;
  15763. /**
  15764. * Minimum power of emitting particles.
  15765. */
  15766. minEmitPower: number;
  15767. /**
  15768. * Maximum power of emitting particles.
  15769. */
  15770. maxEmitPower: number;
  15771. /**
  15772. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15773. */
  15774. minAngularSpeed: number;
  15775. /**
  15776. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15777. */
  15778. maxAngularSpeed: number;
  15779. /**
  15780. * Gets or sets the minimal initial rotation in radians.
  15781. */
  15782. minInitialRotation: number;
  15783. /**
  15784. * Gets or sets the maximal initial rotation in radians.
  15785. */
  15786. maxInitialRotation: number;
  15787. /**
  15788. * The particle emitter type defines the emitter used by the particle system.
  15789. * It can be for example box, sphere, or cone...
  15790. */
  15791. particleEmitterType: Nullable<IParticleEmitterType>;
  15792. /**
  15793. * Defines the delay in milliseconds before starting the system (0 by default)
  15794. */
  15795. startDelay: number;
  15796. /**
  15797. * 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
  15798. */
  15799. preWarmCycles: number;
  15800. /**
  15801. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  15802. */
  15803. preWarmStepOffset: number;
  15804. /**
  15805. * 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)
  15806. */
  15807. spriteCellChangeSpeed: number;
  15808. /**
  15809. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15810. */
  15811. startSpriteCellID: number;
  15812. /**
  15813. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15814. */
  15815. endSpriteCellID: number;
  15816. /**
  15817. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15818. */
  15819. spriteCellWidth: number;
  15820. /**
  15821. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15822. */
  15823. spriteCellHeight: number;
  15824. /**
  15825. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15826. */
  15827. spriteRandomStartCell: boolean;
  15828. /**
  15829. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  15830. */
  15831. isAnimationSheetEnabled: boolean;
  15832. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15833. translationPivot: Vector2;
  15834. /**
  15835. * Gets or sets a texture used to add random noise to particle positions
  15836. */
  15837. noiseTexture: Nullable<BaseTexture>;
  15838. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15839. noiseStrength: Vector3;
  15840. /**
  15841. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15842. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15843. */
  15844. billboardMode: number;
  15845. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15846. limitVelocityDamping: number;
  15847. /**
  15848. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15849. */
  15850. beginAnimationOnStart: boolean;
  15851. /**
  15852. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15853. */
  15854. beginAnimationFrom: number;
  15855. /**
  15856. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15857. */
  15858. beginAnimationTo: number;
  15859. /**
  15860. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15861. */
  15862. beginAnimationLoop: boolean;
  15863. /**
  15864. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  15865. */
  15866. disposeOnStop: boolean;
  15867. /**
  15868. * Gets the maximum number of particles active at the same time.
  15869. * @returns The max number of active particles.
  15870. */
  15871. getCapacity(): number;
  15872. /**
  15873. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15874. * @returns True if it has been started, otherwise false.
  15875. */
  15876. isStarted(): boolean;
  15877. /**
  15878. * Animates the particle system for this frame.
  15879. */
  15880. animate(): void;
  15881. /**
  15882. * Renders the particle system in its current state.
  15883. * @returns the current number of particles
  15884. */
  15885. render(): number;
  15886. /**
  15887. * Dispose the particle system and frees its associated resources.
  15888. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15889. */
  15890. dispose(disposeTexture?: boolean): void;
  15891. /**
  15892. * Clones the particle system.
  15893. * @param name The name of the cloned object
  15894. * @param newEmitter The new emitter to use
  15895. * @returns the cloned particle system
  15896. */
  15897. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  15898. /**
  15899. * Serializes the particle system to a JSON object.
  15900. * @returns the JSON object
  15901. */
  15902. serialize(): any;
  15903. /**
  15904. * Rebuild the particle system
  15905. */
  15906. rebuild(): void;
  15907. /**
  15908. * Starts the particle system and begins to emit
  15909. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  15910. */
  15911. start(delay?: number): void;
  15912. /**
  15913. * Stops the particle system.
  15914. */
  15915. stop(): void;
  15916. /**
  15917. * Remove all active particles
  15918. */
  15919. reset(): void;
  15920. /**
  15921. * Is this system ready to be used/rendered
  15922. * @return true if the system is ready
  15923. */
  15924. isReady(): boolean;
  15925. /**
  15926. * Adds a new color gradient
  15927. * @param gradient defines the gradient to use (between 0 and 1)
  15928. * @param color1 defines the color to affect to the specified gradient
  15929. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15930. * @returns the current particle system
  15931. */
  15932. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15933. /**
  15934. * Remove a specific color gradient
  15935. * @param gradient defines the gradient to remove
  15936. * @returns the current particle system
  15937. */
  15938. removeColorGradient(gradient: number): IParticleSystem;
  15939. /**
  15940. * Adds a new size gradient
  15941. * @param gradient defines the gradient to use (between 0 and 1)
  15942. * @param factor defines the size factor to affect to the specified gradient
  15943. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15944. * @returns the current particle system
  15945. */
  15946. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15947. /**
  15948. * Remove a specific size gradient
  15949. * @param gradient defines the gradient to remove
  15950. * @returns the current particle system
  15951. */
  15952. removeSizeGradient(gradient: number): IParticleSystem;
  15953. /**
  15954. * Gets the current list of color gradients.
  15955. * You must use addColorGradient and removeColorGradient to udpate this list
  15956. * @returns the list of color gradients
  15957. */
  15958. getColorGradients(): Nullable<Array<ColorGradient>>;
  15959. /**
  15960. * Gets the current list of size gradients.
  15961. * You must use addSizeGradient and removeSizeGradient to udpate this list
  15962. * @returns the list of size gradients
  15963. */
  15964. getSizeGradients(): Nullable<Array<FactorGradient>>;
  15965. /**
  15966. * Gets the current list of angular speed gradients.
  15967. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  15968. * @returns the list of angular speed gradients
  15969. */
  15970. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  15971. /**
  15972. * Adds a new angular speed gradient
  15973. * @param gradient defines the gradient to use (between 0 and 1)
  15974. * @param factor defines the angular speed to affect to the specified gradient
  15975. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15976. * @returns the current particle system
  15977. */
  15978. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15979. /**
  15980. * Remove a specific angular speed gradient
  15981. * @param gradient defines the gradient to remove
  15982. * @returns the current particle system
  15983. */
  15984. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15985. /**
  15986. * Gets the current list of velocity gradients.
  15987. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  15988. * @returns the list of velocity gradients
  15989. */
  15990. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15991. /**
  15992. * Adds a new velocity gradient
  15993. * @param gradient defines the gradient to use (between 0 and 1)
  15994. * @param factor defines the velocity to affect to the specified gradient
  15995. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15996. * @returns the current particle system
  15997. */
  15998. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15999. /**
  16000. * Remove a specific velocity gradient
  16001. * @param gradient defines the gradient to remove
  16002. * @returns the current particle system
  16003. */
  16004. removeVelocityGradient(gradient: number): IParticleSystem;
  16005. /**
  16006. * Gets the current list of limit velocity gradients.
  16007. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16008. * @returns the list of limit velocity gradients
  16009. */
  16010. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16011. /**
  16012. * Adds a new limit velocity gradient
  16013. * @param gradient defines the gradient to use (between 0 and 1)
  16014. * @param factor defines the limit velocity to affect to the specified gradient
  16015. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16016. * @returns the current particle system
  16017. */
  16018. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16019. /**
  16020. * Remove a specific limit velocity gradient
  16021. * @param gradient defines the gradient to remove
  16022. * @returns the current particle system
  16023. */
  16024. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16025. /**
  16026. * Adds a new drag gradient
  16027. * @param gradient defines the gradient to use (between 0 and 1)
  16028. * @param factor defines the drag to affect to the specified gradient
  16029. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16030. * @returns the current particle system
  16031. */
  16032. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16033. /**
  16034. * Remove a specific drag gradient
  16035. * @param gradient defines the gradient to remove
  16036. * @returns the current particle system
  16037. */
  16038. removeDragGradient(gradient: number): IParticleSystem;
  16039. /**
  16040. * Gets the current list of drag gradients.
  16041. * You must use addDragGradient and removeDragGradient to udpate this list
  16042. * @returns the list of drag gradients
  16043. */
  16044. getDragGradients(): Nullable<Array<FactorGradient>>;
  16045. /**
  16046. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16047. * @param gradient defines the gradient to use (between 0 and 1)
  16048. * @param factor defines the emit rate to affect to the specified gradient
  16049. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16050. * @returns the current particle system
  16051. */
  16052. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16053. /**
  16054. * Remove a specific emit rate gradient
  16055. * @param gradient defines the gradient to remove
  16056. * @returns the current particle system
  16057. */
  16058. removeEmitRateGradient(gradient: number): IParticleSystem;
  16059. /**
  16060. * Gets the current list of emit rate gradients.
  16061. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16062. * @returns the list of emit rate gradients
  16063. */
  16064. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16065. /**
  16066. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16067. * @param gradient defines the gradient to use (between 0 and 1)
  16068. * @param factor defines the start size to affect to the specified gradient
  16069. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16070. * @returns the current particle system
  16071. */
  16072. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16073. /**
  16074. * Remove a specific start size gradient
  16075. * @param gradient defines the gradient to remove
  16076. * @returns the current particle system
  16077. */
  16078. removeStartSizeGradient(gradient: number): IParticleSystem;
  16079. /**
  16080. * Gets the current list of start size gradients.
  16081. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16082. * @returns the list of start size gradients
  16083. */
  16084. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16085. /**
  16086. * Adds a new life time gradient
  16087. * @param gradient defines the gradient to use (between 0 and 1)
  16088. * @param factor defines the life time factor to affect to the specified gradient
  16089. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16090. * @returns the current particle system
  16091. */
  16092. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16093. /**
  16094. * Remove a specific life time gradient
  16095. * @param gradient defines the gradient to remove
  16096. * @returns the current particle system
  16097. */
  16098. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16099. /**
  16100. * Gets the current list of life time gradients.
  16101. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16102. * @returns the list of life time gradients
  16103. */
  16104. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16105. /**
  16106. * Gets the current list of color gradients.
  16107. * You must use addColorGradient and removeColorGradient to udpate this list
  16108. * @returns the list of color gradients
  16109. */
  16110. getColorGradients(): Nullable<Array<ColorGradient>>;
  16111. /**
  16112. * Adds a new ramp gradient used to remap particle colors
  16113. * @param gradient defines the gradient to use (between 0 and 1)
  16114. * @param color defines the color to affect to the specified gradient
  16115. * @returns the current particle system
  16116. */
  16117. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16118. /**
  16119. * Gets the current list of ramp gradients.
  16120. * You must use addRampGradient and removeRampGradient to udpate this list
  16121. * @returns the list of ramp gradients
  16122. */
  16123. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16124. /** Gets or sets a boolean indicating that ramp gradients must be used
  16125. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16126. */
  16127. useRampGradients: boolean;
  16128. /**
  16129. * Adds a new color remap gradient
  16130. * @param gradient defines the gradient to use (between 0 and 1)
  16131. * @param min defines the color remap minimal range
  16132. * @param max defines the color remap maximal range
  16133. * @returns the current particle system
  16134. */
  16135. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16136. /**
  16137. * Gets the current list of color remap gradients.
  16138. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16139. * @returns the list of color remap gradients
  16140. */
  16141. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16142. /**
  16143. * Adds a new alpha remap gradient
  16144. * @param gradient defines the gradient to use (between 0 and 1)
  16145. * @param min defines the alpha remap minimal range
  16146. * @param max defines the alpha remap maximal range
  16147. * @returns the current particle system
  16148. */
  16149. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16150. /**
  16151. * Gets the current list of alpha remap gradients.
  16152. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16153. * @returns the list of alpha remap gradients
  16154. */
  16155. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16156. /**
  16157. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16158. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16159. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16160. * @returns the emitter
  16161. */
  16162. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16163. /**
  16164. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16165. * @param radius The radius of the hemisphere to emit from
  16166. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16167. * @returns the emitter
  16168. */
  16169. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16170. /**
  16171. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16172. * @param radius The radius of the sphere to emit from
  16173. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16174. * @returns the emitter
  16175. */
  16176. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16177. /**
  16178. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16179. * @param radius The radius of the sphere to emit from
  16180. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16181. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16182. * @returns the emitter
  16183. */
  16184. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16185. /**
  16186. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16187. * @param radius The radius of the emission cylinder
  16188. * @param height The height of the emission cylinder
  16189. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16190. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16191. * @returns the emitter
  16192. */
  16193. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16194. /**
  16195. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16196. * @param radius The radius of the cylinder to emit from
  16197. * @param height The height of the emission cylinder
  16198. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16199. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16200. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16201. * @returns the emitter
  16202. */
  16203. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16204. /**
  16205. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16206. * @param radius The radius of the cone to emit from
  16207. * @param angle The base angle of the cone
  16208. * @returns the emitter
  16209. */
  16210. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16211. /**
  16212. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16213. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16214. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16215. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16216. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16217. * @returns the emitter
  16218. */
  16219. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16220. /**
  16221. * Get hosting scene
  16222. * @returns the scene
  16223. */
  16224. getScene(): Scene;
  16225. }
  16226. }
  16227. declare module BABYLON {
  16228. /**
  16229. * Creates an instance based on a source mesh.
  16230. */
  16231. export class InstancedMesh extends AbstractMesh {
  16232. private _sourceMesh;
  16233. private _currentLOD;
  16234. /** @hidden */ indexInSourceMeshInstanceArray: number;
  16235. constructor(name: string, source: Mesh);
  16236. /**
  16237. * Returns the string "InstancedMesh".
  16238. */
  16239. getClassName(): string;
  16240. /**
  16241. * If the source mesh receives shadows
  16242. */
  16243. readonly receiveShadows: boolean;
  16244. /**
  16245. * The material of the source mesh
  16246. */
  16247. readonly material: Nullable<Material>;
  16248. /**
  16249. * Visibility of the source mesh
  16250. */
  16251. readonly visibility: number;
  16252. /**
  16253. * Skeleton of the source mesh
  16254. */
  16255. readonly skeleton: Nullable<Skeleton>;
  16256. /**
  16257. * Rendering ground id of the source mesh
  16258. */
  16259. renderingGroupId: number;
  16260. /**
  16261. * Returns the total number of vertices (integer).
  16262. */
  16263. getTotalVertices(): number;
  16264. /**
  16265. * Returns a positive integer : the total number of indices in this mesh geometry.
  16266. * @returns the numner of indices or zero if the mesh has no geometry.
  16267. */
  16268. getTotalIndices(): number;
  16269. /**
  16270. * The source mesh of the instance
  16271. */
  16272. readonly sourceMesh: Mesh;
  16273. /**
  16274. * Is this node ready to be used/rendered
  16275. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16276. * @return {boolean} is it ready
  16277. */
  16278. isReady(completeCheck?: boolean): boolean;
  16279. /**
  16280. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16281. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16282. * @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.
  16283. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16284. */
  16285. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16286. /**
  16287. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16288. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16289. * The `data` are either a numeric array either a Float32Array.
  16290. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16291. * 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).
  16292. * Note that a new underlying VertexBuffer object is created each call.
  16293. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16294. *
  16295. * Possible `kind` values :
  16296. * - VertexBuffer.PositionKind
  16297. * - VertexBuffer.UVKind
  16298. * - VertexBuffer.UV2Kind
  16299. * - VertexBuffer.UV3Kind
  16300. * - VertexBuffer.UV4Kind
  16301. * - VertexBuffer.UV5Kind
  16302. * - VertexBuffer.UV6Kind
  16303. * - VertexBuffer.ColorKind
  16304. * - VertexBuffer.MatricesIndicesKind
  16305. * - VertexBuffer.MatricesIndicesExtraKind
  16306. * - VertexBuffer.MatricesWeightsKind
  16307. * - VertexBuffer.MatricesWeightsExtraKind
  16308. *
  16309. * Returns the Mesh.
  16310. */
  16311. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16312. /**
  16313. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16314. * If the mesh has no geometry, it is simply returned as it is.
  16315. * The `data` are either a numeric array either a Float32Array.
  16316. * No new underlying VertexBuffer object is created.
  16317. * 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.
  16318. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16319. *
  16320. * Possible `kind` values :
  16321. * - VertexBuffer.PositionKind
  16322. * - VertexBuffer.UVKind
  16323. * - VertexBuffer.UV2Kind
  16324. * - VertexBuffer.UV3Kind
  16325. * - VertexBuffer.UV4Kind
  16326. * - VertexBuffer.UV5Kind
  16327. * - VertexBuffer.UV6Kind
  16328. * - VertexBuffer.ColorKind
  16329. * - VertexBuffer.MatricesIndicesKind
  16330. * - VertexBuffer.MatricesIndicesExtraKind
  16331. * - VertexBuffer.MatricesWeightsKind
  16332. * - VertexBuffer.MatricesWeightsExtraKind
  16333. *
  16334. * Returns the Mesh.
  16335. */
  16336. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16337. /**
  16338. * Sets the mesh indices.
  16339. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16340. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16341. * This method creates a new index buffer each call.
  16342. * Returns the Mesh.
  16343. */
  16344. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16345. /**
  16346. * Boolean : True if the mesh owns the requested kind of data.
  16347. */
  16348. isVerticesDataPresent(kind: string): boolean;
  16349. /**
  16350. * Returns an array of indices (IndicesArray).
  16351. */
  16352. getIndices(): Nullable<IndicesArray>; protected readonly _positions: Nullable<Vector3[]>;
  16353. /**
  16354. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16355. * This means the mesh underlying bounding box and sphere are recomputed.
  16356. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16357. * @returns the current mesh
  16358. */
  16359. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16360. /** @hidden */ preActivate(): InstancedMesh;
  16361. /** @hidden */ activate(renderId: number): boolean;
  16362. /**
  16363. * Returns the current associated LOD AbstractMesh.
  16364. */
  16365. getLOD(camera: Camera): AbstractMesh;
  16366. /** @hidden */ syncSubMeshes(): InstancedMesh;
  16367. /** @hidden */ generatePointsArray(): boolean;
  16368. /**
  16369. * Creates a new InstancedMesh from the current mesh.
  16370. * - name (string) : the cloned mesh name
  16371. * - newParent (optional Node) : the optional Node to parent the clone to.
  16372. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16373. *
  16374. * Returns the clone.
  16375. */
  16376. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16377. /**
  16378. * Disposes the InstancedMesh.
  16379. * Returns nothing.
  16380. */
  16381. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16382. }
  16383. }
  16384. declare module BABYLON {
  16385. /**
  16386. * Defines the options associated with the creation of a shader material.
  16387. */
  16388. export interface IShaderMaterialOptions {
  16389. /**
  16390. * Does the material work in alpha blend mode
  16391. */
  16392. needAlphaBlending: boolean;
  16393. /**
  16394. * Does the material work in alpha test mode
  16395. */
  16396. needAlphaTesting: boolean;
  16397. /**
  16398. * The list of attribute names used in the shader
  16399. */
  16400. attributes: string[];
  16401. /**
  16402. * The list of unifrom names used in the shader
  16403. */
  16404. uniforms: string[];
  16405. /**
  16406. * The list of UBO names used in the shader
  16407. */
  16408. uniformBuffers: string[];
  16409. /**
  16410. * The list of sampler names used in the shader
  16411. */
  16412. samplers: string[];
  16413. /**
  16414. * The list of defines used in the shader
  16415. */
  16416. defines: string[];
  16417. }
  16418. /**
  16419. * 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.
  16420. *
  16421. * This returned material effects how the mesh will look based on the code in the shaders.
  16422. *
  16423. * @see http://doc.babylonjs.com/how_to/shader_material
  16424. */
  16425. export class ShaderMaterial extends Material {
  16426. private _shaderPath;
  16427. private _options;
  16428. private _textures;
  16429. private _textureArrays;
  16430. private _floats;
  16431. private _ints;
  16432. private _floatsArrays;
  16433. private _colors3;
  16434. private _colors3Arrays;
  16435. private _colors4;
  16436. private _vectors2;
  16437. private _vectors3;
  16438. private _vectors4;
  16439. private _matrices;
  16440. private _matrices3x3;
  16441. private _matrices2x2;
  16442. private _vectors2Arrays;
  16443. private _vectors3Arrays;
  16444. private _cachedWorldViewMatrix;
  16445. private _renderId;
  16446. /**
  16447. * Instantiate a new shader material.
  16448. * 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.
  16449. * This returned material effects how the mesh will look based on the code in the shaders.
  16450. * @see http://doc.babylonjs.com/how_to/shader_material
  16451. * @param name Define the name of the material in the scene
  16452. * @param scene Define the scene the material belongs to
  16453. * @param shaderPath Defines the route to the shader code in one of three ways:
  16454. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16455. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16456. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16457. * @param options Define the options used to create the shader
  16458. */
  16459. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16460. /**
  16461. * Gets the options used to compile the shader.
  16462. * They can be modified to trigger a new compilation
  16463. */
  16464. readonly options: IShaderMaterialOptions;
  16465. /**
  16466. * Gets the current class name of the material e.g. "ShaderMaterial"
  16467. * Mainly use in serialization.
  16468. * @returns the class name
  16469. */
  16470. getClassName(): string;
  16471. /**
  16472. * Specifies if the material will require alpha blending
  16473. * @returns a boolean specifying if alpha blending is needed
  16474. */
  16475. needAlphaBlending(): boolean;
  16476. /**
  16477. * Specifies if this material should be rendered in alpha test mode
  16478. * @returns a boolean specifying if an alpha test is needed.
  16479. */
  16480. needAlphaTesting(): boolean;
  16481. private _checkUniform;
  16482. /**
  16483. * Set a texture in the shader.
  16484. * @param name Define the name of the uniform samplers as defined in the shader
  16485. * @param texture Define the texture to bind to this sampler
  16486. * @return the material itself allowing "fluent" like uniform updates
  16487. */
  16488. setTexture(name: string, texture: Texture): ShaderMaterial;
  16489. /**
  16490. * Set a texture array in the shader.
  16491. * @param name Define the name of the uniform sampler array as defined in the shader
  16492. * @param textures Define the list of textures to bind to this sampler
  16493. * @return the material itself allowing "fluent" like uniform updates
  16494. */
  16495. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16496. /**
  16497. * Set a float in the shader.
  16498. * @param name Define the name of the uniform as defined in the shader
  16499. * @param value Define the value to give to the uniform
  16500. * @return the material itself allowing "fluent" like uniform updates
  16501. */
  16502. setFloat(name: string, value: number): ShaderMaterial;
  16503. /**
  16504. * Set a int in the shader.
  16505. * @param name Define the name of the uniform as defined in the shader
  16506. * @param value Define the value to give to the uniform
  16507. * @return the material itself allowing "fluent" like uniform updates
  16508. */
  16509. setInt(name: string, value: number): ShaderMaterial;
  16510. /**
  16511. * Set an array of floats in the shader.
  16512. * @param name Define the name of the uniform as defined in the shader
  16513. * @param value Define the value to give to the uniform
  16514. * @return the material itself allowing "fluent" like uniform updates
  16515. */
  16516. setFloats(name: string, value: number[]): ShaderMaterial;
  16517. /**
  16518. * Set a vec3 in the shader from a Color3.
  16519. * @param name Define the name of the uniform as defined in the shader
  16520. * @param value Define the value to give to the uniform
  16521. * @return the material itself allowing "fluent" like uniform updates
  16522. */
  16523. setColor3(name: string, value: Color3): ShaderMaterial;
  16524. /**
  16525. * Set a vec3 array in the shader from a Color3 array.
  16526. * @param name Define the name of the uniform as defined in the shader
  16527. * @param value Define the value to give to the uniform
  16528. * @return the material itself allowing "fluent" like uniform updates
  16529. */
  16530. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16531. /**
  16532. * Set a vec4 in the shader from a Color4.
  16533. * @param name Define the name of the uniform as defined in the shader
  16534. * @param value Define the value to give to the uniform
  16535. * @return the material itself allowing "fluent" like uniform updates
  16536. */
  16537. setColor4(name: string, value: Color4): ShaderMaterial;
  16538. /**
  16539. * Set a vec2 in the shader from a Vector2.
  16540. * @param name Define the name of the uniform as defined in the shader
  16541. * @param value Define the value to give to the uniform
  16542. * @return the material itself allowing "fluent" like uniform updates
  16543. */
  16544. setVector2(name: string, value: Vector2): ShaderMaterial;
  16545. /**
  16546. * Set a vec3 in the shader from a Vector3.
  16547. * @param name Define the name of the uniform as defined in the shader
  16548. * @param value Define the value to give to the uniform
  16549. * @return the material itself allowing "fluent" like uniform updates
  16550. */
  16551. setVector3(name: string, value: Vector3): ShaderMaterial;
  16552. /**
  16553. * Set a vec4 in the shader from a Vector4.
  16554. * @param name Define the name of the uniform as defined in the shader
  16555. * @param value Define the value to give to the uniform
  16556. * @return the material itself allowing "fluent" like uniform updates
  16557. */
  16558. setVector4(name: string, value: Vector4): ShaderMaterial;
  16559. /**
  16560. * Set a mat4 in the shader from a Matrix.
  16561. * @param name Define the name of the uniform as defined in the shader
  16562. * @param value Define the value to give to the uniform
  16563. * @return the material itself allowing "fluent" like uniform updates
  16564. */
  16565. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16566. /**
  16567. * Set a mat3 in the shader from a Float32Array.
  16568. * @param name Define the name of the uniform as defined in the shader
  16569. * @param value Define the value to give to the uniform
  16570. * @return the material itself allowing "fluent" like uniform updates
  16571. */
  16572. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16573. /**
  16574. * Set a mat2 in the shader from a Float32Array.
  16575. * @param name Define the name of the uniform as defined in the shader
  16576. * @param value Define the value to give to the uniform
  16577. * @return the material itself allowing "fluent" like uniform updates
  16578. */
  16579. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16580. /**
  16581. * Set a vec2 array in the shader from a number array.
  16582. * @param name Define the name of the uniform as defined in the shader
  16583. * @param value Define the value to give to the uniform
  16584. * @return the material itself allowing "fluent" like uniform updates
  16585. */
  16586. setArray2(name: string, value: number[]): ShaderMaterial;
  16587. /**
  16588. * Set a vec3 array in the shader from a number array.
  16589. * @param name Define the name of the uniform as defined in the shader
  16590. * @param value Define the value to give to the uniform
  16591. * @return the material itself allowing "fluent" like uniform updates
  16592. */
  16593. setArray3(name: string, value: number[]): ShaderMaterial;
  16594. private _checkCache;
  16595. /**
  16596. * Specifies that the submesh is ready to be used
  16597. * @param mesh defines the mesh to check
  16598. * @param subMesh defines which submesh to check
  16599. * @param useInstances specifies that instances should be used
  16600. * @returns a boolean indicating that the submesh is ready or not
  16601. */
  16602. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16603. /**
  16604. * Checks if the material is ready to render the requested mesh
  16605. * @param mesh Define the mesh to render
  16606. * @param useInstances Define whether or not the material is used with instances
  16607. * @returns true if ready, otherwise false
  16608. */
  16609. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16610. /**
  16611. * Binds the world matrix to the material
  16612. * @param world defines the world transformation matrix
  16613. */
  16614. bindOnlyWorldMatrix(world: Matrix): void;
  16615. /**
  16616. * Binds the material to the mesh
  16617. * @param world defines the world transformation matrix
  16618. * @param mesh defines the mesh to bind the material to
  16619. */
  16620. bind(world: Matrix, mesh?: Mesh): void;
  16621. /**
  16622. * Gets the active textures from the material
  16623. * @returns an array of textures
  16624. */
  16625. getActiveTextures(): BaseTexture[];
  16626. /**
  16627. * Specifies if the material uses a texture
  16628. * @param texture defines the texture to check against the material
  16629. * @returns a boolean specifying if the material uses the texture
  16630. */
  16631. hasTexture(texture: BaseTexture): boolean;
  16632. /**
  16633. * Makes a duplicate of the material, and gives it a new name
  16634. * @param name defines the new name for the duplicated material
  16635. * @returns the cloned material
  16636. */
  16637. clone(name: string): ShaderMaterial;
  16638. /**
  16639. * Disposes the material
  16640. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16641. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16642. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16643. */
  16644. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16645. /**
  16646. * Serializes this material in a JSON representation
  16647. * @returns the serialized material object
  16648. */
  16649. serialize(): any;
  16650. /**
  16651. * Creates a shader material from parsed shader material data
  16652. * @param source defines the JSON represnetation of the material
  16653. * @param scene defines the hosting scene
  16654. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16655. * @returns a new material
  16656. */
  16657. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16658. }
  16659. }
  16660. declare module BABYLON {
  16661. /** @hidden */
  16662. export var colorPixelShader: {
  16663. name: string;
  16664. shader: string;
  16665. };
  16666. }
  16667. declare module BABYLON {
  16668. /** @hidden */
  16669. export var colorVertexShader: {
  16670. name: string;
  16671. shader: string;
  16672. };
  16673. }
  16674. declare module BABYLON {
  16675. /**
  16676. * Line mesh
  16677. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16678. */
  16679. export class LinesMesh extends Mesh {
  16680. /**
  16681. * If vertex color should be applied to the mesh
  16682. */
  16683. useVertexColor?: boolean | undefined;
  16684. /**
  16685. * If vertex alpha should be applied to the mesh
  16686. */
  16687. useVertexAlpha?: boolean | undefined;
  16688. /**
  16689. * Color of the line (Default: White)
  16690. */
  16691. color: Color3;
  16692. /**
  16693. * Alpha of the line (Default: 1)
  16694. */
  16695. alpha: number;
  16696. /**
  16697. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16698. * This margin is expressed in world space coordinates, so its value may vary.
  16699. * Default value is 0.1
  16700. */
  16701. intersectionThreshold: number;
  16702. private _colorShader;
  16703. /**
  16704. * Creates a new LinesMesh
  16705. * @param name defines the name
  16706. * @param scene defines the hosting scene
  16707. * @param parent defines the parent mesh if any
  16708. * @param source defines the optional source LinesMesh used to clone data from
  16709. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16710. * When false, achieved by calling a clone(), also passing False.
  16711. * This will make creation of children, recursive.
  16712. * @param useVertexColor defines if this LinesMesh supports vertex color
  16713. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16714. */
  16715. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  16716. /**
  16717. * If vertex color should be applied to the mesh
  16718. */
  16719. useVertexColor?: boolean | undefined,
  16720. /**
  16721. * If vertex alpha should be applied to the mesh
  16722. */
  16723. useVertexAlpha?: boolean | undefined);
  16724. private _addClipPlaneDefine;
  16725. private _removeClipPlaneDefine;
  16726. isReady(): boolean;
  16727. /**
  16728. * Returns the string "LineMesh"
  16729. */
  16730. getClassName(): string;
  16731. /**
  16732. * @hidden
  16733. */
  16734. /**
  16735. * @hidden
  16736. */
  16737. material: Material;
  16738. /**
  16739. * @hidden
  16740. */
  16741. readonly checkCollisions: boolean;
  16742. /** @hidden */ bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  16743. /** @hidden */ draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  16744. /**
  16745. * Disposes of the line mesh
  16746. * @param doNotRecurse If children should be disposed
  16747. */
  16748. dispose(doNotRecurse?: boolean): void;
  16749. /**
  16750. * Returns a new LineMesh object cloned from the current one.
  16751. */
  16752. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  16753. /**
  16754. * Creates a new InstancedLinesMesh object from the mesh model.
  16755. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16756. * @param name defines the name of the new instance
  16757. * @returns a new InstancedLinesMesh
  16758. */
  16759. createInstance(name: string): InstancedLinesMesh;
  16760. }
  16761. /**
  16762. * Creates an instance based on a source LinesMesh
  16763. */
  16764. export class InstancedLinesMesh extends InstancedMesh {
  16765. /**
  16766. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16767. * This margin is expressed in world space coordinates, so its value may vary.
  16768. * Initilized with the intersectionThreshold value of the source LinesMesh
  16769. */
  16770. intersectionThreshold: number;
  16771. constructor(name: string, source: LinesMesh);
  16772. /**
  16773. * Returns the string "InstancedLinesMesh".
  16774. */
  16775. getClassName(): string;
  16776. }
  16777. }
  16778. declare module BABYLON {
  16779. /** @hidden */
  16780. export var linePixelShader: {
  16781. name: string;
  16782. shader: string;
  16783. };
  16784. }
  16785. declare module BABYLON {
  16786. /** @hidden */
  16787. export var lineVertexShader: {
  16788. name: string;
  16789. shader: string;
  16790. };
  16791. }
  16792. declare module BABYLON {
  16793. interface AbstractMesh {
  16794. /**
  16795. * Disables the mesh edge rendering mode
  16796. * @returns the currentAbstractMesh
  16797. */
  16798. disableEdgesRendering(): AbstractMesh;
  16799. /**
  16800. * Enables the edge rendering mode on the mesh.
  16801. * This mode makes the mesh edges visible
  16802. * @param epsilon defines the maximal distance between two angles to detect a face
  16803. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16804. * @returns the currentAbstractMesh
  16805. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16806. */
  16807. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16808. /**
  16809. * Gets the edgesRenderer associated with the mesh
  16810. */
  16811. edgesRenderer: Nullable<EdgesRenderer>;
  16812. }
  16813. interface LinesMesh {
  16814. /**
  16815. * Enables the edge rendering mode on the mesh.
  16816. * This mode makes the mesh edges visible
  16817. * @param epsilon defines the maximal distance between two angles to detect a face
  16818. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16819. * @returns the currentAbstractMesh
  16820. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16821. */
  16822. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16823. }
  16824. interface InstancedLinesMesh {
  16825. /**
  16826. * Enables the edge rendering mode on the mesh.
  16827. * This mode makes the mesh edges visible
  16828. * @param epsilon defines the maximal distance between two angles to detect a face
  16829. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16830. * @returns the current InstancedLinesMesh
  16831. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16832. */
  16833. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16834. }
  16835. /**
  16836. * Defines the minimum contract an Edges renderer should follow.
  16837. */
  16838. export interface IEdgesRenderer extends IDisposable {
  16839. /**
  16840. * Gets or sets a boolean indicating if the edgesRenderer is active
  16841. */
  16842. isEnabled: boolean;
  16843. /**
  16844. * Renders the edges of the attached mesh,
  16845. */
  16846. render(): void;
  16847. /**
  16848. * Checks wether or not the edges renderer is ready to render.
  16849. * @return true if ready, otherwise false.
  16850. */
  16851. isReady(): boolean;
  16852. }
  16853. /**
  16854. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16855. */
  16856. export class EdgesRenderer implements IEdgesRenderer {
  16857. /**
  16858. * Define the size of the edges with an orthographic camera
  16859. */
  16860. edgesWidthScalerForOrthographic: number;
  16861. /**
  16862. * Define the size of the edges with a perspective camera
  16863. */
  16864. edgesWidthScalerForPerspective: number;
  16865. protected _source: AbstractMesh;
  16866. protected _linesPositions: number[];
  16867. protected _linesNormals: number[];
  16868. protected _linesIndices: number[];
  16869. protected _epsilon: number;
  16870. protected _indicesCount: number;
  16871. protected _lineShader: ShaderMaterial;
  16872. protected _ib: WebGLBuffer;
  16873. protected _buffers: {
  16874. [key: string]: Nullable<VertexBuffer>;
  16875. };
  16876. protected _checkVerticesInsteadOfIndices: boolean;
  16877. private _meshRebuildObserver;
  16878. private _meshDisposeObserver;
  16879. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16880. isEnabled: boolean;
  16881. /**
  16882. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16883. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16884. * @param source Mesh used to create edges
  16885. * @param epsilon sum of angles in adjacency to check for edge
  16886. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16887. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16888. */
  16889. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16890. protected _prepareRessources(): void;
  16891. /** @hidden */ rebuild(): void;
  16892. /**
  16893. * Releases the required resources for the edges renderer
  16894. */
  16895. dispose(): void;
  16896. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16897. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16898. /**
  16899. * Checks if the pair of p0 and p1 is en edge
  16900. * @param faceIndex
  16901. * @param edge
  16902. * @param faceNormals
  16903. * @param p0
  16904. * @param p1
  16905. * @private
  16906. */
  16907. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16908. /**
  16909. * push line into the position, normal and index buffer
  16910. * @protected
  16911. */
  16912. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16913. /**
  16914. * Generates lines edges from adjacencjes
  16915. * @private
  16916. */ generateEdgesLines(): void;
  16917. /**
  16918. * Checks wether or not the edges renderer is ready to render.
  16919. * @return true if ready, otherwise false.
  16920. */
  16921. isReady(): boolean;
  16922. /**
  16923. * Renders the edges of the attached mesh,
  16924. */
  16925. render(): void;
  16926. }
  16927. /**
  16928. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16929. */
  16930. export class LineEdgesRenderer extends EdgesRenderer {
  16931. /**
  16932. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16933. * @param source LineMesh used to generate edges
  16934. * @param epsilon not important (specified angle for edge detection)
  16935. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16936. */
  16937. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16938. /**
  16939. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16940. */ generateEdgesLines(): void;
  16941. }
  16942. }
  16943. declare module BABYLON {
  16944. /**
  16945. * This represents the object necessary to create a rendering group.
  16946. * This is exclusively used and created by the rendering manager.
  16947. * To modify the behavior, you use the available helpers in your scene or meshes.
  16948. * @hidden
  16949. */
  16950. export class RenderingGroup {
  16951. index: number;
  16952. private _scene;
  16953. private _opaqueSubMeshes;
  16954. private _transparentSubMeshes;
  16955. private _alphaTestSubMeshes;
  16956. private _depthOnlySubMeshes;
  16957. private _particleSystems;
  16958. private _spriteManagers;
  16959. private _opaqueSortCompareFn;
  16960. private _alphaTestSortCompareFn;
  16961. private _transparentSortCompareFn;
  16962. private _renderOpaque;
  16963. private _renderAlphaTest;
  16964. private _renderTransparent;
  16965. /** @hidden */ edgesRenderers: SmartArray<IEdgesRenderer>;
  16966. onBeforeTransparentRendering: () => void;
  16967. /**
  16968. * Set the opaque sort comparison function.
  16969. * If null the sub meshes will be render in the order they were created
  16970. */
  16971. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16972. /**
  16973. * Set the alpha test sort comparison function.
  16974. * If null the sub meshes will be render in the order they were created
  16975. */
  16976. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16977. /**
  16978. * Set the transparent sort comparison function.
  16979. * If null the sub meshes will be render in the order they were created
  16980. */
  16981. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16982. /**
  16983. * Creates a new rendering group.
  16984. * @param index The rendering group index
  16985. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16986. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16987. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16988. */
  16989. 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>);
  16990. /**
  16991. * Render all the sub meshes contained in the group.
  16992. * @param customRenderFunction Used to override the default render behaviour of the group.
  16993. * @returns true if rendered some submeshes.
  16994. */
  16995. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16996. /**
  16997. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16998. * @param subMeshes The submeshes to render
  16999. */
  17000. private renderOpaqueSorted;
  17001. /**
  17002. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17003. * @param subMeshes The submeshes to render
  17004. */
  17005. private renderAlphaTestSorted;
  17006. /**
  17007. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17008. * @param subMeshes The submeshes to render
  17009. */
  17010. private renderTransparentSorted;
  17011. /**
  17012. * Renders the submeshes in a specified order.
  17013. * @param subMeshes The submeshes to sort before render
  17014. * @param sortCompareFn The comparison function use to sort
  17015. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17016. * @param transparent Specifies to activate blending if true
  17017. */
  17018. private static renderSorted;
  17019. /**
  17020. * Renders the submeshes in the order they were dispatched (no sort applied).
  17021. * @param subMeshes The submeshes to render
  17022. */
  17023. private static renderUnsorted;
  17024. /**
  17025. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17026. * are rendered back to front if in the same alpha index.
  17027. *
  17028. * @param a The first submesh
  17029. * @param b The second submesh
  17030. * @returns The result of the comparison
  17031. */
  17032. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17033. /**
  17034. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17035. * are rendered back to front.
  17036. *
  17037. * @param a The first submesh
  17038. * @param b The second submesh
  17039. * @returns The result of the comparison
  17040. */
  17041. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17042. /**
  17043. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17044. * are rendered front to back (prevent overdraw).
  17045. *
  17046. * @param a The first submesh
  17047. * @param b The second submesh
  17048. * @returns The result of the comparison
  17049. */
  17050. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17051. /**
  17052. * Resets the different lists of submeshes to prepare a new frame.
  17053. */
  17054. prepare(): void;
  17055. dispose(): void;
  17056. /**
  17057. * Inserts the submesh in its correct queue depending on its material.
  17058. * @param subMesh The submesh to dispatch
  17059. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17060. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17061. */
  17062. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17063. dispatchSprites(spriteManager: ISpriteManager): void;
  17064. dispatchParticles(particleSystem: IParticleSystem): void;
  17065. private _renderParticles;
  17066. private _renderSprites;
  17067. }
  17068. }
  17069. declare module BABYLON {
  17070. /**
  17071. * Interface describing the different options available in the rendering manager
  17072. * regarding Auto Clear between groups.
  17073. */
  17074. export interface IRenderingManagerAutoClearSetup {
  17075. /**
  17076. * Defines whether or not autoclear is enable.
  17077. */
  17078. autoClear: boolean;
  17079. /**
  17080. * Defines whether or not to autoclear the depth buffer.
  17081. */
  17082. depth: boolean;
  17083. /**
  17084. * Defines whether or not to autoclear the stencil buffer.
  17085. */
  17086. stencil: boolean;
  17087. }
  17088. /**
  17089. * This class is used by the onRenderingGroupObservable
  17090. */
  17091. export class RenderingGroupInfo {
  17092. /**
  17093. * The Scene that being rendered
  17094. */
  17095. scene: Scene;
  17096. /**
  17097. * The camera currently used for the rendering pass
  17098. */
  17099. camera: Nullable<Camera>;
  17100. /**
  17101. * The ID of the renderingGroup being processed
  17102. */
  17103. renderingGroupId: number;
  17104. }
  17105. /**
  17106. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17107. * It is enable to manage the different groups as well as the different necessary sort functions.
  17108. * This should not be used directly aside of the few static configurations
  17109. */
  17110. export class RenderingManager {
  17111. /**
  17112. * The max id used for rendering groups (not included)
  17113. */
  17114. static MAX_RENDERINGGROUPS: number;
  17115. /**
  17116. * The min id used for rendering groups (included)
  17117. */
  17118. static MIN_RENDERINGGROUPS: number;
  17119. /**
  17120. * Used to globally prevent autoclearing scenes.
  17121. */
  17122. static AUTOCLEAR: boolean;
  17123. /**
  17124. * @hidden
  17125. */ useSceneAutoClearSetup: boolean;
  17126. private _scene;
  17127. private _renderingGroups;
  17128. private _depthStencilBufferAlreadyCleaned;
  17129. private _autoClearDepthStencil;
  17130. private _customOpaqueSortCompareFn;
  17131. private _customAlphaTestSortCompareFn;
  17132. private _customTransparentSortCompareFn;
  17133. private _renderingGroupInfo;
  17134. /**
  17135. * Instantiates a new rendering group for a particular scene
  17136. * @param scene Defines the scene the groups belongs to
  17137. */
  17138. constructor(scene: Scene);
  17139. private _clearDepthStencilBuffer;
  17140. /**
  17141. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17142. * @hidden
  17143. */
  17144. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17145. /**
  17146. * Resets the different information of the group to prepare a new frame
  17147. * @hidden
  17148. */
  17149. reset(): void;
  17150. /**
  17151. * Dispose and release the group and its associated resources.
  17152. * @hidden
  17153. */
  17154. dispose(): void;
  17155. /**
  17156. * Clear the info related to rendering groups preventing retention points during dispose.
  17157. */
  17158. freeRenderingGroups(): void;
  17159. private _prepareRenderingGroup;
  17160. /**
  17161. * Add a sprite manager to the rendering manager in order to render it this frame.
  17162. * @param spriteManager Define the sprite manager to render
  17163. */
  17164. dispatchSprites(spriteManager: ISpriteManager): void;
  17165. /**
  17166. * Add a particle system to the rendering manager in order to render it this frame.
  17167. * @param particleSystem Define the particle system to render
  17168. */
  17169. dispatchParticles(particleSystem: IParticleSystem): void;
  17170. /**
  17171. * Add a submesh to the manager in order to render it this frame
  17172. * @param subMesh The submesh to dispatch
  17173. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17174. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17175. */
  17176. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17177. /**
  17178. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17179. * This allowed control for front to back rendering or reversly depending of the special needs.
  17180. *
  17181. * @param renderingGroupId The rendering group id corresponding to its index
  17182. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17183. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17184. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17185. */
  17186. 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;
  17187. /**
  17188. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17189. *
  17190. * @param renderingGroupId The rendering group id corresponding to its index
  17191. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17192. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17193. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17194. */
  17195. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17196. /**
  17197. * Gets the current auto clear configuration for one rendering group of the rendering
  17198. * manager.
  17199. * @param index the rendering group index to get the information for
  17200. * @returns The auto clear setup for the requested rendering group
  17201. */
  17202. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17203. }
  17204. }
  17205. declare module BABYLON {
  17206. /**
  17207. * This Helps creating a texture that will be created from a camera in your scene.
  17208. * It is basically a dynamic texture that could be used to create special effects for instance.
  17209. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17210. */
  17211. export class RenderTargetTexture extends Texture {
  17212. isCube: boolean;
  17213. /**
  17214. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17215. */
  17216. static readonly REFRESHRATE_RENDER_ONCE: number;
  17217. /**
  17218. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17219. */
  17220. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17221. /**
  17222. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17223. * the central point of your effect and can save a lot of performances.
  17224. */
  17225. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17226. /**
  17227. * Use this predicate to dynamically define the list of mesh you want to render.
  17228. * If set, the renderList property will be overwritten.
  17229. */
  17230. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17231. private _renderList;
  17232. /**
  17233. * Use this list to define the list of mesh you want to render.
  17234. */
  17235. renderList: Nullable<Array<AbstractMesh>>;
  17236. private _hookArray;
  17237. /**
  17238. * Define if particles should be rendered in your texture.
  17239. */
  17240. renderParticles: boolean;
  17241. /**
  17242. * Define if sprites should be rendered in your texture.
  17243. */
  17244. renderSprites: boolean;
  17245. /**
  17246. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17247. */
  17248. coordinatesMode: number;
  17249. /**
  17250. * Define the camera used to render the texture.
  17251. */
  17252. activeCamera: Nullable<Camera>;
  17253. /**
  17254. * Override the render function of the texture with your own one.
  17255. */
  17256. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17257. /**
  17258. * Define if camera post processes should be use while rendering the texture.
  17259. */
  17260. useCameraPostProcesses: boolean;
  17261. /**
  17262. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17263. */
  17264. ignoreCameraViewport: boolean;
  17265. private _postProcessManager;
  17266. private _postProcesses;
  17267. private _resizeObserver;
  17268. /**
  17269. * An event triggered when the texture is unbind.
  17270. */
  17271. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17272. /**
  17273. * An event triggered when the texture is unbind.
  17274. */
  17275. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17276. private _onAfterUnbindObserver;
  17277. /**
  17278. * Set a after unbind callback in the texture.
  17279. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17280. */
  17281. onAfterUnbind: () => void;
  17282. /**
  17283. * An event triggered before rendering the texture
  17284. */
  17285. onBeforeRenderObservable: Observable<number>;
  17286. private _onBeforeRenderObserver;
  17287. /**
  17288. * Set a before render callback in the texture.
  17289. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17290. */
  17291. onBeforeRender: (faceIndex: number) => void;
  17292. /**
  17293. * An event triggered after rendering the texture
  17294. */
  17295. onAfterRenderObservable: Observable<number>;
  17296. private _onAfterRenderObserver;
  17297. /**
  17298. * Set a after render callback in the texture.
  17299. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17300. */
  17301. onAfterRender: (faceIndex: number) => void;
  17302. /**
  17303. * An event triggered after the texture clear
  17304. */
  17305. onClearObservable: Observable<Engine>;
  17306. private _onClearObserver;
  17307. /**
  17308. * Set a clear callback in the texture.
  17309. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17310. */
  17311. onClear: (Engine: Engine) => void;
  17312. /**
  17313. * Define the clear color of the Render Target if it should be different from the scene.
  17314. */
  17315. clearColor: Color4;
  17316. protected _size: number | {
  17317. width: number;
  17318. height: number;
  17319. };
  17320. protected _initialSizeParameter: number | {
  17321. width: number;
  17322. height: number;
  17323. } | {
  17324. ratio: number;
  17325. };
  17326. protected _sizeRatio: Nullable<number>;
  17327. /** @hidden */ generateMipMaps: boolean;
  17328. protected _renderingManager: RenderingManager;
  17329. /** @hidden */ waitingRenderList: string[];
  17330. protected _doNotChangeAspectRatio: boolean;
  17331. protected _currentRefreshId: number;
  17332. protected _refreshRate: number;
  17333. protected _textureMatrix: Matrix;
  17334. protected _samples: number;
  17335. protected _renderTargetOptions: RenderTargetCreationOptions;
  17336. /**
  17337. * Gets render target creation options that were used.
  17338. */
  17339. readonly renderTargetOptions: RenderTargetCreationOptions;
  17340. protected _engine: Engine;
  17341. protected _onRatioRescale(): void;
  17342. /**
  17343. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17344. * It must define where the camera used to render the texture is set
  17345. */
  17346. boundingBoxPosition: Vector3;
  17347. private _boundingBoxSize;
  17348. /**
  17349. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17350. * When defined, the cubemap will switch to local mode
  17351. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17352. * @example https://www.babylonjs-playground.com/#RNASML
  17353. */
  17354. boundingBoxSize: Vector3;
  17355. /**
  17356. * In case the RTT has been created with a depth texture, get the associated
  17357. * depth texture.
  17358. * Otherwise, return null.
  17359. */
  17360. depthStencilTexture: Nullable<InternalTexture>;
  17361. /**
  17362. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17363. * or used a shadow, depth texture...
  17364. * @param name The friendly name of the texture
  17365. * @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)
  17366. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17367. * @param generateMipMaps True if mip maps need to be generated after render.
  17368. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17369. * @param type The type of the buffer in the RTT (int, half float, float...)
  17370. * @param isCube True if a cube texture needs to be created
  17371. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17372. * @param generateDepthBuffer True to generate a depth buffer
  17373. * @param generateStencilBuffer True to generate a stencil buffer
  17374. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17375. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17376. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17377. */
  17378. constructor(name: string, size: number | {
  17379. width: number;
  17380. height: number;
  17381. } | {
  17382. ratio: number;
  17383. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17384. /**
  17385. * Creates a depth stencil texture.
  17386. * This is only available in WebGL 2 or with the depth texture extension available.
  17387. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17388. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17389. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17390. */
  17391. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17392. private _processSizeParameter;
  17393. /**
  17394. * Define the number of samples to use in case of MSAA.
  17395. * It defaults to one meaning no MSAA has been enabled.
  17396. */
  17397. samples: number;
  17398. /**
  17399. * Resets the refresh counter of the texture and start bak from scratch.
  17400. * Could be useful to regenerate the texture if it is setup to render only once.
  17401. */
  17402. resetRefreshCounter(): void;
  17403. /**
  17404. * Define the refresh rate of the texture or the rendering frequency.
  17405. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17406. */
  17407. refreshRate: number;
  17408. /**
  17409. * Adds a post process to the render target rendering passes.
  17410. * @param postProcess define the post process to add
  17411. */
  17412. addPostProcess(postProcess: PostProcess): void;
  17413. /**
  17414. * Clear all the post processes attached to the render target
  17415. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17416. */
  17417. clearPostProcesses(dispose?: boolean): void;
  17418. /**
  17419. * Remove one of the post process from the list of attached post processes to the texture
  17420. * @param postProcess define the post process to remove from the list
  17421. */
  17422. removePostProcess(postProcess: PostProcess): void;
  17423. /** @hidden */ shouldRender(): boolean;
  17424. /**
  17425. * Gets the actual render size of the texture.
  17426. * @returns the width of the render size
  17427. */
  17428. getRenderSize(): number;
  17429. /**
  17430. * Gets the actual render width of the texture.
  17431. * @returns the width of the render size
  17432. */
  17433. getRenderWidth(): number;
  17434. /**
  17435. * Gets the actual render height of the texture.
  17436. * @returns the height of the render size
  17437. */
  17438. getRenderHeight(): number;
  17439. /**
  17440. * Get if the texture can be rescaled or not.
  17441. */
  17442. readonly canRescale: boolean;
  17443. /**
  17444. * Resize the texture using a ratio.
  17445. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17446. */
  17447. scale(ratio: number): void;
  17448. /**
  17449. * Get the texture reflection matrix used to rotate/transform the reflection.
  17450. * @returns the reflection matrix
  17451. */
  17452. getReflectionTextureMatrix(): Matrix;
  17453. /**
  17454. * Resize the texture to a new desired size.
  17455. * Be carrefull as it will recreate all the data in the new texture.
  17456. * @param size Define the new size. It can be:
  17457. * - a number for squared texture,
  17458. * - an object containing { width: number, height: number }
  17459. * - or an object containing a ratio { ratio: number }
  17460. */
  17461. resize(size: number | {
  17462. width: number;
  17463. height: number;
  17464. } | {
  17465. ratio: number;
  17466. }): void;
  17467. /**
  17468. * Renders all the objects from the render list into the texture.
  17469. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17470. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17471. */
  17472. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17473. private _bestReflectionRenderTargetDimension;
  17474. /**
  17475. * @hidden
  17476. * @param faceIndex face index to bind to if this is a cubetexture
  17477. */ bindFrameBuffer(faceIndex?: number): void;
  17478. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17479. private renderToTarget;
  17480. /**
  17481. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17482. * This allowed control for front to back rendering or reversly depending of the special needs.
  17483. *
  17484. * @param renderingGroupId The rendering group id corresponding to its index
  17485. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17486. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17487. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17488. */
  17489. 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;
  17490. /**
  17491. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17492. *
  17493. * @param renderingGroupId The rendering group id corresponding to its index
  17494. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17495. */
  17496. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17497. /**
  17498. * Clones the texture.
  17499. * @returns the cloned texture
  17500. */
  17501. clone(): RenderTargetTexture;
  17502. /**
  17503. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17504. * @returns The JSON representation of the texture
  17505. */
  17506. serialize(): any;
  17507. /**
  17508. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17509. */
  17510. disposeFramebufferObjects(): void;
  17511. /**
  17512. * Dispose the texture and release its associated resources.
  17513. */
  17514. dispose(): void;
  17515. /** @hidden */ rebuild(): void;
  17516. /**
  17517. * Clear the info related to rendering groups preventing retention point in material dispose.
  17518. */
  17519. freeRenderingGroups(): void;
  17520. /**
  17521. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17522. * @returns the view count
  17523. */
  17524. getViewCount(): number;
  17525. }
  17526. }
  17527. declare module BABYLON {
  17528. /**
  17529. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17530. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17531. * You can then easily use it as a reflectionTexture on a flat surface.
  17532. * In case the surface is not a plane, please consider relying on reflection probes.
  17533. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17534. */
  17535. export class MirrorTexture extends RenderTargetTexture {
  17536. private scene;
  17537. /**
  17538. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17539. * 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.
  17540. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17541. */
  17542. mirrorPlane: Plane;
  17543. /**
  17544. * Define the blur ratio used to blur the reflection if needed.
  17545. */
  17546. blurRatio: number;
  17547. /**
  17548. * Define the adaptive blur kernel used to blur the reflection if needed.
  17549. * This will autocompute the closest best match for the `blurKernel`
  17550. */
  17551. adaptiveBlurKernel: number;
  17552. /**
  17553. * Define the blur kernel used to blur the reflection if needed.
  17554. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17555. */
  17556. blurKernel: number;
  17557. /**
  17558. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17559. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17560. */
  17561. blurKernelX: number;
  17562. /**
  17563. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17564. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17565. */
  17566. blurKernelY: number;
  17567. private _autoComputeBlurKernel;
  17568. protected _onRatioRescale(): void;
  17569. private _updateGammaSpace;
  17570. private _imageProcessingConfigChangeObserver;
  17571. private _transformMatrix;
  17572. private _mirrorMatrix;
  17573. private _savedViewMatrix;
  17574. private _blurX;
  17575. private _blurY;
  17576. private _adaptiveBlurKernel;
  17577. private _blurKernelX;
  17578. private _blurKernelY;
  17579. private _blurRatio;
  17580. /**
  17581. * Instantiates a Mirror Texture.
  17582. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17583. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17584. * You can then easily use it as a reflectionTexture on a flat surface.
  17585. * In case the surface is not a plane, please consider relying on reflection probes.
  17586. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17587. * @param name
  17588. * @param size
  17589. * @param scene
  17590. * @param generateMipMaps
  17591. * @param type
  17592. * @param samplingMode
  17593. * @param generateDepthBuffer
  17594. */
  17595. constructor(name: string, size: number | {
  17596. width: number;
  17597. height: number;
  17598. } | {
  17599. ratio: number;
  17600. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17601. private _preparePostProcesses;
  17602. /**
  17603. * Clone the mirror texture.
  17604. * @returns the cloned texture
  17605. */
  17606. clone(): MirrorTexture;
  17607. /**
  17608. * Serialize the texture to a JSON representation you could use in Parse later on
  17609. * @returns the serialized JSON representation
  17610. */
  17611. serialize(): any;
  17612. /**
  17613. * Dispose the texture and release its associated resources.
  17614. */
  17615. dispose(): void;
  17616. }
  17617. }
  17618. declare module BABYLON {
  17619. /**
  17620. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17621. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17622. */
  17623. export class Texture extends BaseTexture {
  17624. /** @hidden */ private static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  17625. /** @hidden */ private static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  17626. /** @hidden */ private static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  17627. /** nearest is mag = nearest and min = nearest and mip = linear */
  17628. static readonly NEAREST_SAMPLINGMODE: number;
  17629. /** nearest is mag = nearest and min = nearest and mip = linear */
  17630. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  17631. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17632. static readonly BILINEAR_SAMPLINGMODE: number;
  17633. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17634. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  17635. /** Trilinear is mag = linear and min = linear and mip = linear */
  17636. static readonly TRILINEAR_SAMPLINGMODE: number;
  17637. /** Trilinear is mag = linear and min = linear and mip = linear */
  17638. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  17639. /** mag = nearest and min = nearest and mip = nearest */
  17640. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  17641. /** mag = nearest and min = linear and mip = nearest */
  17642. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  17643. /** mag = nearest and min = linear and mip = linear */
  17644. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  17645. /** mag = nearest and min = linear and mip = none */
  17646. static readonly NEAREST_LINEAR: number;
  17647. /** mag = nearest and min = nearest and mip = none */
  17648. static readonly NEAREST_NEAREST: number;
  17649. /** mag = linear and min = nearest and mip = nearest */
  17650. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  17651. /** mag = linear and min = nearest and mip = linear */
  17652. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  17653. /** mag = linear and min = linear and mip = none */
  17654. static readonly LINEAR_LINEAR: number;
  17655. /** mag = linear and min = nearest and mip = none */
  17656. static readonly LINEAR_NEAREST: number;
  17657. /** Explicit coordinates mode */
  17658. static readonly EXPLICIT_MODE: number;
  17659. /** Spherical coordinates mode */
  17660. static readonly SPHERICAL_MODE: number;
  17661. /** Planar coordinates mode */
  17662. static readonly PLANAR_MODE: number;
  17663. /** Cubic coordinates mode */
  17664. static readonly CUBIC_MODE: number;
  17665. /** Projection coordinates mode */
  17666. static readonly PROJECTION_MODE: number;
  17667. /** Inverse Cubic coordinates mode */
  17668. static readonly SKYBOX_MODE: number;
  17669. /** Inverse Cubic coordinates mode */
  17670. static readonly INVCUBIC_MODE: number;
  17671. /** Equirectangular coordinates mode */
  17672. static readonly EQUIRECTANGULAR_MODE: number;
  17673. /** Equirectangular Fixed coordinates mode */
  17674. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  17675. /** Equirectangular Fixed Mirrored coordinates mode */
  17676. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  17677. /** Texture is not repeating outside of 0..1 UVs */
  17678. static readonly CLAMP_ADDRESSMODE: number;
  17679. /** Texture is repeating outside of 0..1 UVs */
  17680. static readonly WRAP_ADDRESSMODE: number;
  17681. /** Texture is repeating and mirrored */
  17682. static readonly MIRROR_ADDRESSMODE: number;
  17683. /**
  17684. * 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
  17685. */
  17686. static UseSerializedUrlIfAny: boolean;
  17687. /**
  17688. * Define the url of the texture.
  17689. */
  17690. url: Nullable<string>;
  17691. /**
  17692. * Define an offset on the texture to offset the u coordinates of the UVs
  17693. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17694. */
  17695. uOffset: number;
  17696. /**
  17697. * Define an offset on the texture to offset the v coordinates of the UVs
  17698. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17699. */
  17700. vOffset: number;
  17701. /**
  17702. * Define an offset on the texture to scale the u coordinates of the UVs
  17703. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17704. */
  17705. uScale: number;
  17706. /**
  17707. * Define an offset on the texture to scale the v coordinates of the UVs
  17708. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17709. */
  17710. vScale: number;
  17711. /**
  17712. * Define an offset on the texture to rotate around the u coordinates of the UVs
  17713. * @see http://doc.babylonjs.com/how_to/more_materials
  17714. */
  17715. uAng: number;
  17716. /**
  17717. * Define an offset on the texture to rotate around the v coordinates of the UVs
  17718. * @see http://doc.babylonjs.com/how_to/more_materials
  17719. */
  17720. vAng: number;
  17721. /**
  17722. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  17723. * @see http://doc.babylonjs.com/how_to/more_materials
  17724. */
  17725. wAng: number;
  17726. /**
  17727. * Defines the center of rotation (U)
  17728. */
  17729. uRotationCenter: number;
  17730. /**
  17731. * Defines the center of rotation (V)
  17732. */
  17733. vRotationCenter: number;
  17734. /**
  17735. * Defines the center of rotation (W)
  17736. */
  17737. wRotationCenter: number;
  17738. /**
  17739. * Are mip maps generated for this texture or not.
  17740. */
  17741. readonly noMipmap: boolean;
  17742. /**
  17743. * List of inspectable custom properties (used by the Inspector)
  17744. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  17745. */
  17746. inspectableCustomProperties: IInspectable[];
  17747. private _noMipmap;
  17748. /** @hidden */ invertY: boolean;
  17749. private _rowGenerationMatrix;
  17750. private _cachedTextureMatrix;
  17751. private _projectionModeMatrix;
  17752. private _t0;
  17753. private _t1;
  17754. private _t2;
  17755. private _cachedUOffset;
  17756. private _cachedVOffset;
  17757. private _cachedUScale;
  17758. private _cachedVScale;
  17759. private _cachedUAng;
  17760. private _cachedVAng;
  17761. private _cachedWAng;
  17762. private _cachedProjectionMatrixId;
  17763. private _cachedCoordinatesMode;
  17764. /** @hidden */
  17765. protected _initialSamplingMode: number;
  17766. /** @hidden */ buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  17767. private _deleteBuffer;
  17768. protected _format: Nullable<number>;
  17769. private _delayedOnLoad;
  17770. private _delayedOnError;
  17771. /**
  17772. * Observable triggered once the texture has been loaded.
  17773. */
  17774. onLoadObservable: Observable<Texture>;
  17775. protected _isBlocking: boolean;
  17776. /**
  17777. * Is the texture preventing material to render while loading.
  17778. * If false, a default texture will be used instead of the loading one during the preparation step.
  17779. */
  17780. isBlocking: boolean;
  17781. /**
  17782. * Get the current sampling mode associated with the texture.
  17783. */
  17784. readonly samplingMode: number;
  17785. /**
  17786. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  17787. */
  17788. readonly invertY: boolean;
  17789. /**
  17790. * Instantiates a new texture.
  17791. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17792. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17793. * @param url define the url of the picture to load as a texture
  17794. * @param scene define the scene the texture will belong to
  17795. * @param noMipmap define if the texture will require mip maps or not
  17796. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17797. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17798. * @param onLoad define a callback triggered when the texture has been loaded
  17799. * @param onError define a callback triggered when an error occurred during the loading session
  17800. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  17801. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  17802. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17803. */
  17804. 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);
  17805. /**
  17806. * Update the url (and optional buffer) of this texture if url was null during construction.
  17807. * @param url the url of the texture
  17808. * @param buffer the buffer of the texture (defaults to null)
  17809. * @param onLoad callback called when the texture is loaded (defaults to null)
  17810. */
  17811. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  17812. /**
  17813. * Finish the loading sequence of a texture flagged as delayed load.
  17814. * @hidden
  17815. */
  17816. delayLoad(): void;
  17817. private _prepareRowForTextureGeneration;
  17818. /**
  17819. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  17820. * @returns the transform matrix of the texture.
  17821. */
  17822. getTextureMatrix(): Matrix;
  17823. /**
  17824. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  17825. * @returns The reflection texture transform
  17826. */
  17827. getReflectionTextureMatrix(): Matrix;
  17828. /**
  17829. * Clones the texture.
  17830. * @returns the cloned texture
  17831. */
  17832. clone(): Texture;
  17833. /**
  17834. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17835. * @returns The JSON representation of the texture
  17836. */
  17837. serialize(): any;
  17838. /**
  17839. * Get the current class name of the texture useful for serialization or dynamic coding.
  17840. * @returns "Texture"
  17841. */
  17842. getClassName(): string;
  17843. /**
  17844. * Dispose the texture and release its associated resources.
  17845. */
  17846. dispose(): void;
  17847. /**
  17848. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  17849. * @param parsedTexture Define the JSON representation of the texture
  17850. * @param scene Define the scene the parsed texture should be instantiated in
  17851. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  17852. * @returns The parsed texture if successful
  17853. */
  17854. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  17855. /**
  17856. * Creates a texture from its base 64 representation.
  17857. * @param data Define the base64 payload without the data: prefix
  17858. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  17859. * @param scene Define the scene the texture should belong to
  17860. * @param noMipmap Forces the texture to not create mip map information if true
  17861. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17862. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17863. * @param onLoad define a callback triggered when the texture has been loaded
  17864. * @param onError define a callback triggered when an error occurred during the loading session
  17865. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17866. * @returns the created texture
  17867. */
  17868. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  17869. /**
  17870. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  17871. * @param data Define the base64 payload without the data: prefix
  17872. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  17873. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  17874. * @param scene Define the scene the texture should belong to
  17875. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  17876. * @param noMipmap Forces the texture to not create mip map information if true
  17877. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17878. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17879. * @param onLoad define a callback triggered when the texture has been loaded
  17880. * @param onError define a callback triggered when an error occurred during the loading session
  17881. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17882. * @returns the created texture
  17883. */
  17884. 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;
  17885. }
  17886. }
  17887. declare module BABYLON {
  17888. /**
  17889. * Raw texture can help creating a texture directly from an array of data.
  17890. * This can be super useful if you either get the data from an uncompressed source or
  17891. * if you wish to create your texture pixel by pixel.
  17892. */
  17893. export class RawTexture extends Texture {
  17894. /**
  17895. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  17896. */
  17897. format: number;
  17898. private _engine;
  17899. /**
  17900. * Instantiates a new RawTexture.
  17901. * Raw texture can help creating a texture directly from an array of data.
  17902. * This can be super useful if you either get the data from an uncompressed source or
  17903. * if you wish to create your texture pixel by pixel.
  17904. * @param data define the array of data to use to create the texture
  17905. * @param width define the width of the texture
  17906. * @param height define the height of the texture
  17907. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  17908. * @param scene define the scene the texture belongs to
  17909. * @param generateMipMaps define whether mip maps should be generated or not
  17910. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17911. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17912. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  17913. */
  17914. constructor(data: ArrayBufferView, width: number, height: number,
  17915. /**
  17916. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  17917. */
  17918. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  17919. /**
  17920. * Updates the texture underlying data.
  17921. * @param data Define the new data of the texture
  17922. */
  17923. update(data: ArrayBufferView): void;
  17924. /**
  17925. * Creates a luminance texture from some data.
  17926. * @param data Define the texture data
  17927. * @param width Define the width of the texture
  17928. * @param height Define the height of the texture
  17929. * @param scene Define the scene the texture belongs to
  17930. * @param generateMipMaps Define whether or not to create mip maps for the texture
  17931. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17932. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17933. * @returns the luminance texture
  17934. */
  17935. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  17936. /**
  17937. * Creates a luminance alpha texture from some data.
  17938. * @param data Define the texture data
  17939. * @param width Define the width of the texture
  17940. * @param height Define the height of the texture
  17941. * @param scene Define the scene the texture belongs to
  17942. * @param generateMipMaps Define whether or not to create mip maps for the texture
  17943. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17944. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17945. * @returns the luminance alpha texture
  17946. */
  17947. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  17948. /**
  17949. * Creates an alpha texture from some data.
  17950. * @param data Define the texture data
  17951. * @param width Define the width of the texture
  17952. * @param height Define the height of the texture
  17953. * @param scene Define the scene the texture belongs to
  17954. * @param generateMipMaps Define whether or not to create mip maps for the texture
  17955. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17956. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17957. * @returns the alpha texture
  17958. */
  17959. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  17960. /**
  17961. * Creates a RGB texture from some data.
  17962. * @param data Define the texture data
  17963. * @param width Define the width of the texture
  17964. * @param height Define the height of the texture
  17965. * @param scene Define the scene the texture belongs to
  17966. * @param generateMipMaps Define whether or not to create mip maps for the texture
  17967. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17968. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17969. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  17970. * @returns the RGB alpha texture
  17971. */
  17972. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  17973. /**
  17974. * Creates a RGBA texture from some data.
  17975. * @param data Define the texture data
  17976. * @param width Define the width of the texture
  17977. * @param height Define the height of the texture
  17978. * @param scene Define the scene the texture belongs to
  17979. * @param generateMipMaps Define whether or not to create mip maps for the texture
  17980. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17981. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17982. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  17983. * @returns the RGBA texture
  17984. */
  17985. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  17986. /**
  17987. * Creates a R texture from some data.
  17988. * @param data Define the texture data
  17989. * @param width Define the width of the texture
  17990. * @param height Define the height of the texture
  17991. * @param scene Define the scene the texture belongs to
  17992. * @param generateMipMaps Define whether or not to create mip maps for the texture
  17993. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17994. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17995. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  17996. * @returns the R texture
  17997. */
  17998. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  17999. }
  18000. }
  18001. declare module BABYLON {
  18002. /**
  18003. * Defines a runtime animation
  18004. */
  18005. export class RuntimeAnimation {
  18006. private _events;
  18007. /**
  18008. * The current frame of the runtime animation
  18009. */
  18010. private _currentFrame;
  18011. /**
  18012. * The animation used by the runtime animation
  18013. */
  18014. private _animation;
  18015. /**
  18016. * The target of the runtime animation
  18017. */
  18018. private _target;
  18019. /**
  18020. * The initiating animatable
  18021. */
  18022. private _host;
  18023. /**
  18024. * The original value of the runtime animation
  18025. */
  18026. private _originalValue;
  18027. /**
  18028. * The original blend value of the runtime animation
  18029. */
  18030. private _originalBlendValue;
  18031. /**
  18032. * The offsets cache of the runtime animation
  18033. */
  18034. private _offsetsCache;
  18035. /**
  18036. * The high limits cache of the runtime animation
  18037. */
  18038. private _highLimitsCache;
  18039. /**
  18040. * Specifies if the runtime animation has been stopped
  18041. */
  18042. private _stopped;
  18043. /**
  18044. * The blending factor of the runtime animation
  18045. */
  18046. private _blendingFactor;
  18047. /**
  18048. * The BabylonJS scene
  18049. */
  18050. private _scene;
  18051. /**
  18052. * The current value of the runtime animation
  18053. */
  18054. private _currentValue;
  18055. /** @hidden */ workValue: any;
  18056. /**
  18057. * The active target of the runtime animation
  18058. */
  18059. private _activeTargets;
  18060. private _currentActiveTarget;
  18061. private _directTarget;
  18062. /**
  18063. * The target path of the runtime animation
  18064. */
  18065. private _targetPath;
  18066. /**
  18067. * The weight of the runtime animation
  18068. */
  18069. private _weight;
  18070. /**
  18071. * The ratio offset of the runtime animation
  18072. */
  18073. private _ratioOffset;
  18074. /**
  18075. * The previous delay of the runtime animation
  18076. */
  18077. private _previousDelay;
  18078. /**
  18079. * The previous ratio of the runtime animation
  18080. */
  18081. private _previousRatio;
  18082. private _enableBlending;
  18083. private _correctLoopMode;
  18084. private _keys;
  18085. private _minFrame;
  18086. private _maxFrame;
  18087. private _minValue;
  18088. private _maxValue;
  18089. /**
  18090. * Gets the current frame of the runtime animation
  18091. */
  18092. readonly currentFrame: number;
  18093. /**
  18094. * Gets the weight of the runtime animation
  18095. */
  18096. readonly weight: number;
  18097. /**
  18098. * Gets the current value of the runtime animation
  18099. */
  18100. readonly currentValue: any;
  18101. /**
  18102. * Gets the target path of the runtime animation
  18103. */
  18104. readonly targetPath: string;
  18105. /**
  18106. * Gets the actual target of the runtime animation
  18107. */
  18108. readonly target: any;
  18109. /**
  18110. * Create a new RuntimeAnimation object
  18111. * @param target defines the target of the animation
  18112. * @param animation defines the source animation object
  18113. * @param scene defines the hosting scene
  18114. * @param host defines the initiating Animatable
  18115. */
  18116. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18117. private _normalizationProcessor;
  18118. private _defaultNormalizationProcessor;
  18119. private _preparePath;
  18120. /**
  18121. * Gets the animation from the runtime animation
  18122. */
  18123. readonly animation: Animation;
  18124. /**
  18125. * Resets the runtime animation to the beginning
  18126. * @param restoreOriginal defines whether to restore the target property to the original value
  18127. */
  18128. reset(restoreOriginal?: boolean): void;
  18129. /**
  18130. * Specifies if the runtime animation is stopped
  18131. * @returns Boolean specifying if the runtime animation is stopped
  18132. */
  18133. isStopped(): boolean;
  18134. /**
  18135. * Disposes of the runtime animation
  18136. */
  18137. dispose(): void;
  18138. /**
  18139. * Interpolates the animation from the current frame
  18140. * @param currentFrame The frame to interpolate the animation to
  18141. * @param repeatCount The number of times that the animation should loop
  18142. * @param loopMode The type of looping mode to use
  18143. * @param offsetValue Animation offset value
  18144. * @param highLimitValue The high limit value
  18145. * @returns The interpolated value
  18146. */
  18147. private _interpolate;
  18148. /**
  18149. * Apply the interpolated value to the target
  18150. */
  18151. setValue: (currentValue: any, weight: number) => void;
  18152. private _setValueForArray;
  18153. private _setValueForDirect;
  18154. private _getOriginalValues;
  18155. private _activeBlendingProcessor;
  18156. private _noBlendingProcessor;
  18157. private _blendingProcessor;
  18158. private _setValue;
  18159. /**
  18160. * Gets the loop pmode of the runtime animation
  18161. * @returns Loop Mode
  18162. */
  18163. private _getCorrectLoopMode;
  18164. /**
  18165. * Move the current animation to a given frame
  18166. * @param frame defines the frame to move to
  18167. */
  18168. goToFrame(frame: number): void;
  18169. /**
  18170. * @hidden Internal use only
  18171. */ prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18172. /**
  18173. * Execute the current animation
  18174. * @param delay defines the delay to add to the current frame
  18175. * @param from defines the lower bound of the animation range
  18176. * @param to defines the upper bound of the animation range
  18177. * @param loop defines if the current animation must loop
  18178. * @param speedRatio defines the current speed ratio
  18179. * @param weight defines the weight of the animation (default is -1 so no weight)
  18180. * @param onLoop optional callback called when animation loops
  18181. * @returns a boolean indicating if the animation is running
  18182. */
  18183. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18184. }
  18185. }
  18186. declare module BABYLON {
  18187. /**
  18188. * Class used to store an actual running animation
  18189. */
  18190. export class Animatable {
  18191. /** defines the target object */
  18192. target: any;
  18193. /** defines the starting frame number (default is 0) */
  18194. fromFrame: number;
  18195. /** defines the ending frame number (default is 100) */
  18196. toFrame: number;
  18197. /** defines if the animation must loop (default is false) */
  18198. loopAnimation: boolean;
  18199. /** defines a callback to call when animation ends if it is not looping */
  18200. onAnimationEnd?: (() => void) | null | undefined;
  18201. /** defines a callback to call when animation loops */
  18202. onAnimationLoop?: (() => void) | null | undefined;
  18203. private _localDelayOffset;
  18204. private _pausedDelay;
  18205. private _runtimeAnimations;
  18206. private _paused;
  18207. private _scene;
  18208. private _speedRatio;
  18209. private _weight;
  18210. private _syncRoot;
  18211. /**
  18212. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18213. * This will only apply for non looping animation (default is true)
  18214. */
  18215. disposeOnEnd: boolean;
  18216. /**
  18217. * Gets a boolean indicating if the animation has started
  18218. */
  18219. animationStarted: boolean;
  18220. /**
  18221. * Observer raised when the animation ends
  18222. */
  18223. onAnimationEndObservable: Observable<Animatable>;
  18224. /**
  18225. * Observer raised when the animation loops
  18226. */
  18227. onAnimationLoopObservable: Observable<Animatable>;
  18228. /**
  18229. * Gets the root Animatable used to synchronize and normalize animations
  18230. */
  18231. readonly syncRoot: Animatable;
  18232. /**
  18233. * Gets the current frame of the first RuntimeAnimation
  18234. * Used to synchronize Animatables
  18235. */
  18236. readonly masterFrame: number;
  18237. /**
  18238. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18239. */
  18240. weight: number;
  18241. /**
  18242. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18243. */
  18244. speedRatio: number;
  18245. /**
  18246. * Creates a new Animatable
  18247. * @param scene defines the hosting scene
  18248. * @param target defines the target object
  18249. * @param fromFrame defines the starting frame number (default is 0)
  18250. * @param toFrame defines the ending frame number (default is 100)
  18251. * @param loopAnimation defines if the animation must loop (default is false)
  18252. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18253. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18254. * @param animations defines a group of animation to add to the new Animatable
  18255. * @param onAnimationLoop defines a callback to call when animation loops
  18256. */
  18257. constructor(scene: Scene,
  18258. /** defines the target object */
  18259. target: any,
  18260. /** defines the starting frame number (default is 0) */
  18261. fromFrame?: number,
  18262. /** defines the ending frame number (default is 100) */
  18263. toFrame?: number,
  18264. /** defines if the animation must loop (default is false) */
  18265. loopAnimation?: boolean, speedRatio?: number,
  18266. /** defines a callback to call when animation ends if it is not looping */
  18267. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18268. /** defines a callback to call when animation loops */
  18269. onAnimationLoop?: (() => void) | null | undefined);
  18270. /**
  18271. * Synchronize and normalize current Animatable with a source Animatable
  18272. * This is useful when using animation weights and when animations are not of the same length
  18273. * @param root defines the root Animatable to synchronize with
  18274. * @returns the current Animatable
  18275. */
  18276. syncWith(root: Animatable): Animatable;
  18277. /**
  18278. * Gets the list of runtime animations
  18279. * @returns an array of RuntimeAnimation
  18280. */
  18281. getAnimations(): RuntimeAnimation[];
  18282. /**
  18283. * Adds more animations to the current animatable
  18284. * @param target defines the target of the animations
  18285. * @param animations defines the new animations to add
  18286. */
  18287. appendAnimations(target: any, animations: Animation[]): void;
  18288. /**
  18289. * Gets the source animation for a specific property
  18290. * @param property defines the propertyu to look for
  18291. * @returns null or the source animation for the given property
  18292. */
  18293. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18294. /**
  18295. * Gets the runtime animation for a specific property
  18296. * @param property defines the propertyu to look for
  18297. * @returns null or the runtime animation for the given property
  18298. */
  18299. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18300. /**
  18301. * Resets the animatable to its original state
  18302. */
  18303. reset(): void;
  18304. /**
  18305. * Allows the animatable to blend with current running animations
  18306. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18307. * @param blendingSpeed defines the blending speed to use
  18308. */
  18309. enableBlending(blendingSpeed: number): void;
  18310. /**
  18311. * Disable animation blending
  18312. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18313. */
  18314. disableBlending(): void;
  18315. /**
  18316. * Jump directly to a given frame
  18317. * @param frame defines the frame to jump to
  18318. */
  18319. goToFrame(frame: number): void;
  18320. /**
  18321. * Pause the animation
  18322. */
  18323. pause(): void;
  18324. /**
  18325. * Restart the animation
  18326. */
  18327. restart(): void;
  18328. private _raiseOnAnimationEnd;
  18329. /**
  18330. * Stop and delete the current animation
  18331. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18332. * @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)
  18333. */
  18334. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18335. /**
  18336. * Wait asynchronously for the animation to end
  18337. * @returns a promise which will be fullfilled when the animation ends
  18338. */
  18339. waitAsync(): Promise<Animatable>;
  18340. /** @hidden */ animate(delay: number): boolean;
  18341. }
  18342. interface Scene {
  18343. /** @hidden */ registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18344. /** @hidden */ processLateAnimationBindingsForMatrices(holder: {
  18345. totalWeight: number;
  18346. animations: RuntimeAnimation[];
  18347. originalValue: Matrix;
  18348. }): any;
  18349. /** @hidden */ processLateAnimationBindingsForQuaternions(holder: {
  18350. totalWeight: number;
  18351. animations: RuntimeAnimation[];
  18352. originalValue: Quaternion;
  18353. }, refQuaternion: Quaternion): Quaternion;
  18354. /** @hidden */ processLateAnimationBindings(): void;
  18355. /**
  18356. * Will start the animation sequence of a given target
  18357. * @param target defines the target
  18358. * @param from defines from which frame should animation start
  18359. * @param to defines until which frame should animation run.
  18360. * @param weight defines the weight to apply to the animation (1.0 by default)
  18361. * @param loop defines if the animation loops
  18362. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18363. * @param onAnimationEnd defines the function to be executed when the animation ends
  18364. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18365. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18366. * @param onAnimationLoop defines the callback to call when an animation loops
  18367. * @returns the animatable object created for this animation
  18368. */
  18369. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18370. /**
  18371. * Will start the animation sequence of a given target
  18372. * @param target defines the target
  18373. * @param from defines from which frame should animation start
  18374. * @param to defines until which frame should animation run.
  18375. * @param loop defines if the animation loops
  18376. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18377. * @param onAnimationEnd defines the function to be executed when the animation ends
  18378. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18379. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18380. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18381. * @param onAnimationLoop defines the callback to call when an animation loops
  18382. * @returns the animatable object created for this animation
  18383. */
  18384. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18385. /**
  18386. * Will start the animation sequence of a given target and its hierarchy
  18387. * @param target defines the target
  18388. * @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.
  18389. * @param from defines from which frame should animation start
  18390. * @param to defines until which frame should animation run.
  18391. * @param loop defines if the animation loops
  18392. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18393. * @param onAnimationEnd defines the function to be executed when the animation ends
  18394. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18395. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18396. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18397. * @param onAnimationLoop defines the callback to call when an animation loops
  18398. * @returns the list of created animatables
  18399. */
  18400. 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[];
  18401. /**
  18402. * Begin a new animation on a given node
  18403. * @param target defines the target where the animation will take place
  18404. * @param animations defines the list of animations to start
  18405. * @param from defines the initial value
  18406. * @param to defines the final value
  18407. * @param loop defines if you want animation to loop (off by default)
  18408. * @param speedRatio defines the speed ratio to apply to all animations
  18409. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18410. * @param onAnimationLoop defines the callback to call when an animation loops
  18411. * @returns the list of created animatables
  18412. */
  18413. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18414. /**
  18415. * Begin a new animation on a given node and its hierarchy
  18416. * @param target defines the root node where the animation will take place
  18417. * @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.
  18418. * @param animations defines the list of animations to start
  18419. * @param from defines the initial value
  18420. * @param to defines the final value
  18421. * @param loop defines if you want animation to loop (off by default)
  18422. * @param speedRatio defines the speed ratio to apply to all animations
  18423. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18424. * @param onAnimationLoop defines the callback to call when an animation loops
  18425. * @returns the list of animatables created for all nodes
  18426. */
  18427. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18428. /**
  18429. * Gets the animatable associated with a specific target
  18430. * @param target defines the target of the animatable
  18431. * @returns the required animatable if found
  18432. */
  18433. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18434. /**
  18435. * Gets all animatables associated with a given target
  18436. * @param target defines the target to look animatables for
  18437. * @returns an array of Animatables
  18438. */
  18439. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18440. /**
  18441. * Will stop the animation of the given target
  18442. * @param target - the target
  18443. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  18444. * @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)
  18445. */
  18446. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  18447. /**
  18448. * Stops and removes all animations that have been applied to the scene
  18449. */
  18450. stopAllAnimations(): void;
  18451. }
  18452. interface Bone {
  18453. /**
  18454. * Copy an animation range from another bone
  18455. * @param source defines the source bone
  18456. * @param rangeName defines the range name to copy
  18457. * @param frameOffset defines the frame offset
  18458. * @param rescaleAsRequired defines if rescaling must be applied if required
  18459. * @param skelDimensionsRatio defines the scaling ratio
  18460. * @returns true if operation was successful
  18461. */
  18462. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18463. }
  18464. }
  18465. declare module BABYLON {
  18466. /**
  18467. * Class used to handle skinning animations
  18468. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18469. */
  18470. export class Skeleton implements IAnimatable {
  18471. /** defines the skeleton name */
  18472. name: string;
  18473. /** defines the skeleton Id */
  18474. id: string;
  18475. /**
  18476. * Defines the list of child bones
  18477. */
  18478. bones: Bone[];
  18479. /**
  18480. * Defines an estimate of the dimension of the skeleton at rest
  18481. */
  18482. dimensionsAtRest: Vector3;
  18483. /**
  18484. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18485. */
  18486. needInitialSkinMatrix: boolean;
  18487. /**
  18488. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18489. */
  18490. overrideMesh: Nullable<AbstractMesh>;
  18491. /**
  18492. * Gets the list of animations attached to this skeleton
  18493. */
  18494. animations: Array<Animation>;
  18495. private _scene;
  18496. private _isDirty;
  18497. private _transformMatrices;
  18498. private _transformMatrixTexture;
  18499. private _meshesWithPoseMatrix;
  18500. private _animatables;
  18501. private _identity;
  18502. private _synchronizedWithMesh;
  18503. private _ranges;
  18504. private _lastAbsoluteTransformsUpdateId;
  18505. private _canUseTextureForBones;
  18506. private _uniqueId;
  18507. /** @hidden */ numBonesWithLinkedTransformNode: number;
  18508. /**
  18509. * Specifies if the skeleton should be serialized
  18510. */
  18511. doNotSerialize: boolean;
  18512. private _useTextureToStoreBoneMatrices;
  18513. /**
  18514. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  18515. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  18516. */
  18517. useTextureToStoreBoneMatrices: boolean;
  18518. private _animationPropertiesOverride;
  18519. /**
  18520. * Gets or sets the animation properties override
  18521. */
  18522. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18523. /**
  18524. * List of inspectable custom properties (used by the Inspector)
  18525. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18526. */
  18527. inspectableCustomProperties: IInspectable[];
  18528. /**
  18529. * An observable triggered before computing the skeleton's matrices
  18530. */
  18531. onBeforeComputeObservable: Observable<Skeleton>;
  18532. /**
  18533. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  18534. */
  18535. readonly isUsingTextureForMatrices: boolean;
  18536. /**
  18537. * Gets the unique ID of this skeleton
  18538. */
  18539. readonly uniqueId: number;
  18540. /**
  18541. * Creates a new skeleton
  18542. * @param name defines the skeleton name
  18543. * @param id defines the skeleton Id
  18544. * @param scene defines the hosting scene
  18545. */
  18546. constructor(
  18547. /** defines the skeleton name */
  18548. name: string,
  18549. /** defines the skeleton Id */
  18550. id: string, scene: Scene);
  18551. /**
  18552. * Gets the current object class name.
  18553. * @return the class name
  18554. */
  18555. getClassName(): string;
  18556. /**
  18557. * Returns an array containing the root bones
  18558. * @returns an array containing the root bones
  18559. */
  18560. getChildren(): Array<Bone>;
  18561. /**
  18562. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  18563. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  18564. * @returns a Float32Array containing matrices data
  18565. */
  18566. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  18567. /**
  18568. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  18569. * @returns a raw texture containing the data
  18570. */
  18571. getTransformMatrixTexture(): Nullable<RawTexture>;
  18572. /**
  18573. * Gets the current hosting scene
  18574. * @returns a scene object
  18575. */
  18576. getScene(): Scene;
  18577. /**
  18578. * Gets a string representing the current skeleton data
  18579. * @param fullDetails defines a boolean indicating if we want a verbose version
  18580. * @returns a string representing the current skeleton data
  18581. */
  18582. toString(fullDetails?: boolean): string;
  18583. /**
  18584. * Get bone's index searching by name
  18585. * @param name defines bone's name to search for
  18586. * @return the indice of the bone. Returns -1 if not found
  18587. */
  18588. getBoneIndexByName(name: string): number;
  18589. /**
  18590. * Creater a new animation range
  18591. * @param name defines the name of the range
  18592. * @param from defines the start key
  18593. * @param to defines the end key
  18594. */
  18595. createAnimationRange(name: string, from: number, to: number): void;
  18596. /**
  18597. * Delete a specific animation range
  18598. * @param name defines the name of the range
  18599. * @param deleteFrames defines if frames must be removed as well
  18600. */
  18601. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  18602. /**
  18603. * Gets a specific animation range
  18604. * @param name defines the name of the range to look for
  18605. * @returns the requested animation range or null if not found
  18606. */
  18607. getAnimationRange(name: string): Nullable<AnimationRange>;
  18608. /**
  18609. * Gets the list of all animation ranges defined on this skeleton
  18610. * @returns an array
  18611. */
  18612. getAnimationRanges(): Nullable<AnimationRange>[];
  18613. /**
  18614. * Copy animation range from a source skeleton.
  18615. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  18616. * @param source defines the source skeleton
  18617. * @param name defines the name of the range to copy
  18618. * @param rescaleAsRequired defines if rescaling must be applied if required
  18619. * @returns true if operation was successful
  18620. */
  18621. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  18622. /**
  18623. * Forces the skeleton to go to rest pose
  18624. */
  18625. returnToRest(): void;
  18626. private _getHighestAnimationFrame;
  18627. /**
  18628. * Begin a specific animation range
  18629. * @param name defines the name of the range to start
  18630. * @param loop defines if looping must be turned on (false by default)
  18631. * @param speedRatio defines the speed ratio to apply (1 by default)
  18632. * @param onAnimationEnd defines a callback which will be called when animation will end
  18633. * @returns a new animatable
  18634. */
  18635. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  18636. /** @hidden */ markAsDirty(): void;
  18637. /** @hidden */ registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18638. /** @hidden */ unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18639. private _computeTransformMatrices;
  18640. /**
  18641. * Build all resources required to render a skeleton
  18642. */
  18643. prepare(): void;
  18644. /**
  18645. * Gets the list of animatables currently running for this skeleton
  18646. * @returns an array of animatables
  18647. */
  18648. getAnimatables(): IAnimatable[];
  18649. /**
  18650. * Clone the current skeleton
  18651. * @param name defines the name of the new skeleton
  18652. * @param id defines the id of the enw skeleton
  18653. * @returns the new skeleton
  18654. */
  18655. clone(name: string, id: string): Skeleton;
  18656. /**
  18657. * Enable animation blending for this skeleton
  18658. * @param blendingSpeed defines the blending speed to apply
  18659. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18660. */
  18661. enableBlending(blendingSpeed?: number): void;
  18662. /**
  18663. * Releases all resources associated with the current skeleton
  18664. */
  18665. dispose(): void;
  18666. /**
  18667. * Serialize the skeleton in a JSON object
  18668. * @returns a JSON object
  18669. */
  18670. serialize(): any;
  18671. /**
  18672. * Creates a new skeleton from serialized data
  18673. * @param parsedSkeleton defines the serialized data
  18674. * @param scene defines the hosting scene
  18675. * @returns a new skeleton
  18676. */
  18677. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  18678. /**
  18679. * Compute all node absolute transforms
  18680. * @param forceUpdate defines if computation must be done even if cache is up to date
  18681. */
  18682. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  18683. /**
  18684. * Gets the root pose matrix
  18685. * @returns a matrix
  18686. */
  18687. getPoseMatrix(): Nullable<Matrix>;
  18688. /**
  18689. * Sorts bones per internal index
  18690. */
  18691. sortBones(): void;
  18692. private _sortBones;
  18693. }
  18694. }
  18695. declare module BABYLON {
  18696. /**
  18697. * Defines a target to use with MorphTargetManager
  18698. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18699. */
  18700. export class MorphTarget implements IAnimatable {
  18701. /** defines the name of the target */
  18702. name: string;
  18703. /**
  18704. * Gets or sets the list of animations
  18705. */
  18706. animations: Animation[];
  18707. private _scene;
  18708. private _positions;
  18709. private _normals;
  18710. private _tangents;
  18711. private _influence;
  18712. /**
  18713. * Observable raised when the influence changes
  18714. */
  18715. onInfluenceChanged: Observable<boolean>;
  18716. /** @hidden */ onDataLayoutChanged: Observable<void>;
  18717. /**
  18718. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  18719. */
  18720. influence: number;
  18721. /**
  18722. * Gets or sets the id of the morph Target
  18723. */
  18724. id: string;
  18725. private _animationPropertiesOverride;
  18726. /**
  18727. * Gets or sets the animation properties override
  18728. */
  18729. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18730. /**
  18731. * Creates a new MorphTarget
  18732. * @param name defines the name of the target
  18733. * @param influence defines the influence to use
  18734. * @param scene defines the scene the morphtarget belongs to
  18735. */
  18736. constructor(
  18737. /** defines the name of the target */
  18738. name: string, influence?: number, scene?: Nullable<Scene>);
  18739. /**
  18740. * Gets a boolean defining if the target contains position data
  18741. */
  18742. readonly hasPositions: boolean;
  18743. /**
  18744. * Gets a boolean defining if the target contains normal data
  18745. */
  18746. readonly hasNormals: boolean;
  18747. /**
  18748. * Gets a boolean defining if the target contains tangent data
  18749. */
  18750. readonly hasTangents: boolean;
  18751. /**
  18752. * Affects position data to this target
  18753. * @param data defines the position data to use
  18754. */
  18755. setPositions(data: Nullable<FloatArray>): void;
  18756. /**
  18757. * Gets the position data stored in this target
  18758. * @returns a FloatArray containing the position data (or null if not present)
  18759. */
  18760. getPositions(): Nullable<FloatArray>;
  18761. /**
  18762. * Affects normal data to this target
  18763. * @param data defines the normal data to use
  18764. */
  18765. setNormals(data: Nullable<FloatArray>): void;
  18766. /**
  18767. * Gets the normal data stored in this target
  18768. * @returns a FloatArray containing the normal data (or null if not present)
  18769. */
  18770. getNormals(): Nullable<FloatArray>;
  18771. /**
  18772. * Affects tangent data to this target
  18773. * @param data defines the tangent data to use
  18774. */
  18775. setTangents(data: Nullable<FloatArray>): void;
  18776. /**
  18777. * Gets the tangent data stored in this target
  18778. * @returns a FloatArray containing the tangent data (or null if not present)
  18779. */
  18780. getTangents(): Nullable<FloatArray>;
  18781. /**
  18782. * Serializes the current target into a Serialization object
  18783. * @returns the serialized object
  18784. */
  18785. serialize(): any;
  18786. /**
  18787. * Returns the string "MorphTarget"
  18788. * @returns "MorphTarget"
  18789. */
  18790. getClassName(): string;
  18791. /**
  18792. * Creates a new target from serialized data
  18793. * @param serializationObject defines the serialized data to use
  18794. * @returns a new MorphTarget
  18795. */
  18796. static Parse(serializationObject: any): MorphTarget;
  18797. /**
  18798. * Creates a MorphTarget from mesh data
  18799. * @param mesh defines the source mesh
  18800. * @param name defines the name to use for the new target
  18801. * @param influence defines the influence to attach to the target
  18802. * @returns a new MorphTarget
  18803. */
  18804. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  18805. }
  18806. }
  18807. declare module BABYLON {
  18808. /**
  18809. * This class is used to deform meshes using morphing between different targets
  18810. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18811. */
  18812. export class MorphTargetManager {
  18813. private _targets;
  18814. private _targetInfluenceChangedObservers;
  18815. private _targetDataLayoutChangedObservers;
  18816. private _activeTargets;
  18817. private _scene;
  18818. private _influences;
  18819. private _supportsNormals;
  18820. private _supportsTangents;
  18821. private _vertexCount;
  18822. private _uniqueId;
  18823. private _tempInfluences;
  18824. /**
  18825. * Creates a new MorphTargetManager
  18826. * @param scene defines the current scene
  18827. */
  18828. constructor(scene?: Nullable<Scene>);
  18829. /**
  18830. * Gets the unique ID of this manager
  18831. */
  18832. readonly uniqueId: number;
  18833. /**
  18834. * Gets the number of vertices handled by this manager
  18835. */
  18836. readonly vertexCount: number;
  18837. /**
  18838. * Gets a boolean indicating if this manager supports morphing of normals
  18839. */
  18840. readonly supportsNormals: boolean;
  18841. /**
  18842. * Gets a boolean indicating if this manager supports morphing of tangents
  18843. */
  18844. readonly supportsTangents: boolean;
  18845. /**
  18846. * Gets the number of targets stored in this manager
  18847. */
  18848. readonly numTargets: number;
  18849. /**
  18850. * Gets the number of influencers (ie. the number of targets with influences > 0)
  18851. */
  18852. readonly numInfluencers: number;
  18853. /**
  18854. * Gets the list of influences (one per target)
  18855. */
  18856. readonly influences: Float32Array;
  18857. /**
  18858. * Gets the active target at specified index. An active target is a target with an influence > 0
  18859. * @param index defines the index to check
  18860. * @returns the requested target
  18861. */
  18862. getActiveTarget(index: number): MorphTarget;
  18863. /**
  18864. * Gets the target at specified index
  18865. * @param index defines the index to check
  18866. * @returns the requested target
  18867. */
  18868. getTarget(index: number): MorphTarget;
  18869. /**
  18870. * Add a new target to this manager
  18871. * @param target defines the target to add
  18872. */
  18873. addTarget(target: MorphTarget): void;
  18874. /**
  18875. * Removes a target from the manager
  18876. * @param target defines the target to remove
  18877. */
  18878. removeTarget(target: MorphTarget): void;
  18879. /**
  18880. * Serializes the current manager into a Serialization object
  18881. * @returns the serialized object
  18882. */
  18883. serialize(): any;
  18884. private _syncActiveTargets;
  18885. /**
  18886. * Syncrhonize the targets with all the meshes using this morph target manager
  18887. */
  18888. synchronize(): void;
  18889. /**
  18890. * Creates a new MorphTargetManager from serialized data
  18891. * @param serializationObject defines the serialized data
  18892. * @param scene defines the hosting scene
  18893. * @returns the new MorphTargetManager
  18894. */
  18895. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  18896. }
  18897. }
  18898. declare module BABYLON {
  18899. /**
  18900. * Mesh representing the gorund
  18901. */
  18902. export class GroundMesh extends Mesh {
  18903. /** If octree should be generated */
  18904. generateOctree: boolean;
  18905. private _heightQuads;
  18906. /** @hidden */ subdivisionsX: number;
  18907. /** @hidden */ subdivisionsY: number;
  18908. /** @hidden */ width: number;
  18909. /** @hidden */ height: number;
  18910. /** @hidden */ minX: number;
  18911. /** @hidden */ maxX: number;
  18912. /** @hidden */ minZ: number;
  18913. /** @hidden */ maxZ: number;
  18914. constructor(name: string, scene: Scene);
  18915. /**
  18916. * "GroundMesh"
  18917. * @returns "GroundMesh"
  18918. */
  18919. getClassName(): string;
  18920. /**
  18921. * The minimum of x and y subdivisions
  18922. */
  18923. readonly subdivisions: number;
  18924. /**
  18925. * X subdivisions
  18926. */
  18927. readonly subdivisionsX: number;
  18928. /**
  18929. * Y subdivisions
  18930. */
  18931. readonly subdivisionsY: number;
  18932. /**
  18933. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  18934. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  18935. * @param chunksCount the number of subdivisions for x and y
  18936. * @param octreeBlocksSize (Default: 32)
  18937. */
  18938. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  18939. /**
  18940. * Returns a height (y) value in the Worl system :
  18941. * the ground altitude at the coordinates (x, z) expressed in the World system.
  18942. * @param x x coordinate
  18943. * @param z z coordinate
  18944. * @returns the ground y position if (x, z) are outside the ground surface.
  18945. */
  18946. getHeightAtCoordinates(x: number, z: number): number;
  18947. /**
  18948. * Returns a normalized vector (Vector3) orthogonal to the ground
  18949. * at the ground coordinates (x, z) expressed in the World system.
  18950. * @param x x coordinate
  18951. * @param z z coordinate
  18952. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  18953. */
  18954. getNormalAtCoordinates(x: number, z: number): Vector3;
  18955. /**
  18956. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  18957. * at the ground coordinates (x, z) expressed in the World system.
  18958. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  18959. * @param x x coordinate
  18960. * @param z z coordinate
  18961. * @param ref vector to store the result
  18962. * @returns the GroundMesh.
  18963. */
  18964. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  18965. /**
  18966. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  18967. * if the ground has been updated.
  18968. * This can be used in the render loop.
  18969. * @returns the GroundMesh.
  18970. */
  18971. updateCoordinateHeights(): GroundMesh;
  18972. private _getFacetAt;
  18973. private _initHeightQuads;
  18974. private _computeHeightQuads;
  18975. /**
  18976. * Serializes this ground mesh
  18977. * @param serializationObject object to write serialization to
  18978. */
  18979. serialize(serializationObject: any): void;
  18980. /**
  18981. * Parses a serialized ground mesh
  18982. * @param parsedMesh the serialized mesh
  18983. * @param scene the scene to create the ground mesh in
  18984. * @returns the created ground mesh
  18985. */
  18986. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  18987. }
  18988. }
  18989. declare module BABYLON {
  18990. /**
  18991. * Interface for Physics-Joint data
  18992. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18993. */
  18994. export interface PhysicsJointData {
  18995. /**
  18996. * The main pivot of the joint
  18997. */
  18998. mainPivot?: Vector3;
  18999. /**
  19000. * The connected pivot of the joint
  19001. */
  19002. connectedPivot?: Vector3;
  19003. /**
  19004. * The main axis of the joint
  19005. */
  19006. mainAxis?: Vector3;
  19007. /**
  19008. * The connected axis of the joint
  19009. */
  19010. connectedAxis?: Vector3;
  19011. /**
  19012. * The collision of the joint
  19013. */
  19014. collision?: boolean;
  19015. /**
  19016. * Native Oimo/Cannon/Energy data
  19017. */
  19018. nativeParams?: any;
  19019. }
  19020. /**
  19021. * This is a holder class for the physics joint created by the physics plugin
  19022. * It holds a set of functions to control the underlying joint
  19023. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19024. */
  19025. export class PhysicsJoint {
  19026. /**
  19027. * The type of the physics joint
  19028. */
  19029. type: number;
  19030. /**
  19031. * The data for the physics joint
  19032. */
  19033. jointData: PhysicsJointData;
  19034. private _physicsJoint;
  19035. protected _physicsPlugin: IPhysicsEnginePlugin;
  19036. /**
  19037. * Initializes the physics joint
  19038. * @param type The type of the physics joint
  19039. * @param jointData The data for the physics joint
  19040. */
  19041. constructor(
  19042. /**
  19043. * The type of the physics joint
  19044. */
  19045. type: number,
  19046. /**
  19047. * The data for the physics joint
  19048. */
  19049. jointData: PhysicsJointData);
  19050. /**
  19051. * Gets the physics joint
  19052. */
  19053. /**
  19054. * Sets the physics joint
  19055. */
  19056. physicsJoint: any;
  19057. /**
  19058. * Sets the physics plugin
  19059. */
  19060. physicsPlugin: IPhysicsEnginePlugin;
  19061. /**
  19062. * Execute a function that is physics-plugin specific.
  19063. * @param {Function} func the function that will be executed.
  19064. * It accepts two parameters: the physics world and the physics joint
  19065. */
  19066. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19067. /**
  19068. * Distance-Joint type
  19069. */
  19070. static DistanceJoint: number;
  19071. /**
  19072. * Hinge-Joint type
  19073. */
  19074. static HingeJoint: number;
  19075. /**
  19076. * Ball-and-Socket joint type
  19077. */
  19078. static BallAndSocketJoint: number;
  19079. /**
  19080. * Wheel-Joint type
  19081. */
  19082. static WheelJoint: number;
  19083. /**
  19084. * Slider-Joint type
  19085. */
  19086. static SliderJoint: number;
  19087. /**
  19088. * Prismatic-Joint type
  19089. */
  19090. static PrismaticJoint: number;
  19091. /**
  19092. * Universal-Joint type
  19093. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19094. */
  19095. static UniversalJoint: number;
  19096. /**
  19097. * Hinge-Joint 2 type
  19098. */
  19099. static Hinge2Joint: number;
  19100. /**
  19101. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19102. */
  19103. static PointToPointJoint: number;
  19104. /**
  19105. * Spring-Joint type
  19106. */
  19107. static SpringJoint: number;
  19108. /**
  19109. * Lock-Joint type
  19110. */
  19111. static LockJoint: number;
  19112. }
  19113. /**
  19114. * A class representing a physics distance joint
  19115. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19116. */
  19117. export class DistanceJoint extends PhysicsJoint {
  19118. /**
  19119. *
  19120. * @param jointData The data for the Distance-Joint
  19121. */
  19122. constructor(jointData: DistanceJointData);
  19123. /**
  19124. * Update the predefined distance.
  19125. * @param maxDistance The maximum preferred distance
  19126. * @param minDistance The minimum preferred distance
  19127. */
  19128. updateDistance(maxDistance: number, minDistance?: number): void;
  19129. }
  19130. /**
  19131. * Represents a Motor-Enabled Joint
  19132. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19133. */
  19134. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19135. /**
  19136. * Initializes the Motor-Enabled Joint
  19137. * @param type The type of the joint
  19138. * @param jointData The physica joint data for the joint
  19139. */
  19140. constructor(type: number, jointData: PhysicsJointData);
  19141. /**
  19142. * Set the motor values.
  19143. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19144. * @param force the force to apply
  19145. * @param maxForce max force for this motor.
  19146. */
  19147. setMotor(force?: number, maxForce?: number): void;
  19148. /**
  19149. * Set the motor's limits.
  19150. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19151. * @param upperLimit The upper limit of the motor
  19152. * @param lowerLimit The lower limit of the motor
  19153. */
  19154. setLimit(upperLimit: number, lowerLimit?: number): void;
  19155. }
  19156. /**
  19157. * This class represents a single physics Hinge-Joint
  19158. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19159. */
  19160. export class HingeJoint extends MotorEnabledJoint {
  19161. /**
  19162. * Initializes the Hinge-Joint
  19163. * @param jointData The joint data for the Hinge-Joint
  19164. */
  19165. constructor(jointData: PhysicsJointData);
  19166. /**
  19167. * Set the motor values.
  19168. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19169. * @param {number} force the force to apply
  19170. * @param {number} maxForce max force for this motor.
  19171. */
  19172. setMotor(force?: number, maxForce?: number): void;
  19173. /**
  19174. * Set the motor's limits.
  19175. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19176. * @param upperLimit The upper limit of the motor
  19177. * @param lowerLimit The lower limit of the motor
  19178. */
  19179. setLimit(upperLimit: number, lowerLimit?: number): void;
  19180. }
  19181. /**
  19182. * This class represents a dual hinge physics joint (same as wheel joint)
  19183. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19184. */
  19185. export class Hinge2Joint extends MotorEnabledJoint {
  19186. /**
  19187. * Initializes the Hinge2-Joint
  19188. * @param jointData The joint data for the Hinge2-Joint
  19189. */
  19190. constructor(jointData: PhysicsJointData);
  19191. /**
  19192. * Set the motor values.
  19193. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19194. * @param {number} targetSpeed the speed the motor is to reach
  19195. * @param {number} maxForce max force for this motor.
  19196. * @param {motorIndex} the motor's index, 0 or 1.
  19197. */
  19198. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19199. /**
  19200. * Set the motor limits.
  19201. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19202. * @param {number} upperLimit the upper limit
  19203. * @param {number} lowerLimit lower limit
  19204. * @param {motorIndex} the motor's index, 0 or 1.
  19205. */
  19206. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19207. }
  19208. /**
  19209. * Interface for a motor enabled joint
  19210. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19211. */
  19212. export interface IMotorEnabledJoint {
  19213. /**
  19214. * Physics joint
  19215. */
  19216. physicsJoint: any;
  19217. /**
  19218. * Sets the motor of the motor-enabled joint
  19219. * @param force The force of the motor
  19220. * @param maxForce The maximum force of the motor
  19221. * @param motorIndex The index of the motor
  19222. */
  19223. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19224. /**
  19225. * Sets the limit of the motor
  19226. * @param upperLimit The upper limit of the motor
  19227. * @param lowerLimit The lower limit of the motor
  19228. * @param motorIndex The index of the motor
  19229. */
  19230. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19231. }
  19232. /**
  19233. * Joint data for a Distance-Joint
  19234. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19235. */
  19236. export interface DistanceJointData extends PhysicsJointData {
  19237. /**
  19238. * Max distance the 2 joint objects can be apart
  19239. */
  19240. maxDistance: number;
  19241. }
  19242. /**
  19243. * Joint data from a spring joint
  19244. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19245. */
  19246. export interface SpringJointData extends PhysicsJointData {
  19247. /**
  19248. * Length of the spring
  19249. */
  19250. length: number;
  19251. /**
  19252. * Stiffness of the spring
  19253. */
  19254. stiffness: number;
  19255. /**
  19256. * Damping of the spring
  19257. */
  19258. damping: number;
  19259. /** this callback will be called when applying the force to the impostors. */
  19260. forceApplicationCallback: () => void;
  19261. }
  19262. }
  19263. declare module BABYLON {
  19264. /**
  19265. * Holds the data for the raycast result
  19266. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19267. */
  19268. export class PhysicsRaycastResult {
  19269. private _hasHit;
  19270. private _hitDistance;
  19271. private _hitNormalWorld;
  19272. private _hitPointWorld;
  19273. private _rayFromWorld;
  19274. private _rayToWorld;
  19275. /**
  19276. * Gets if there was a hit
  19277. */
  19278. readonly hasHit: boolean;
  19279. /**
  19280. * Gets the distance from the hit
  19281. */
  19282. readonly hitDistance: number;
  19283. /**
  19284. * Gets the hit normal/direction in the world
  19285. */
  19286. readonly hitNormalWorld: Vector3;
  19287. /**
  19288. * Gets the hit point in the world
  19289. */
  19290. readonly hitPointWorld: Vector3;
  19291. /**
  19292. * Gets the ray "start point" of the ray in the world
  19293. */
  19294. readonly rayFromWorld: Vector3;
  19295. /**
  19296. * Gets the ray "end point" of the ray in the world
  19297. */
  19298. readonly rayToWorld: Vector3;
  19299. /**
  19300. * Sets the hit data (normal & point in world space)
  19301. * @param hitNormalWorld defines the normal in world space
  19302. * @param hitPointWorld defines the point in world space
  19303. */
  19304. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  19305. /**
  19306. * Sets the distance from the start point to the hit point
  19307. * @param distance
  19308. */
  19309. setHitDistance(distance: number): void;
  19310. /**
  19311. * Calculates the distance manually
  19312. */
  19313. calculateHitDistance(): void;
  19314. /**
  19315. * Resets all the values to default
  19316. * @param from The from point on world space
  19317. * @param to The to point on world space
  19318. */
  19319. reset(from?: Vector3, to?: Vector3): void;
  19320. }
  19321. /**
  19322. * Interface for the size containing width and height
  19323. */
  19324. interface IXYZ {
  19325. /**
  19326. * X
  19327. */
  19328. x: number;
  19329. /**
  19330. * Y
  19331. */
  19332. y: number;
  19333. /**
  19334. * Z
  19335. */
  19336. z: number;
  19337. }
  19338. }
  19339. declare module BABYLON {
  19340. /**
  19341. * Interface used to describe a physics joint
  19342. */
  19343. export interface PhysicsImpostorJoint {
  19344. /** Defines the main impostor to which the joint is linked */
  19345. mainImpostor: PhysicsImpostor;
  19346. /** Defines the impostor that is connected to the main impostor using this joint */
  19347. connectedImpostor: PhysicsImpostor;
  19348. /** Defines the joint itself */
  19349. joint: PhysicsJoint;
  19350. }
  19351. /** @hidden */
  19352. export interface IPhysicsEnginePlugin {
  19353. world: any;
  19354. name: string;
  19355. setGravity(gravity: Vector3): void;
  19356. setTimeStep(timeStep: number): void;
  19357. getTimeStep(): number;
  19358. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19359. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19360. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19361. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19362. removePhysicsBody(impostor: PhysicsImpostor): void;
  19363. generateJoint(joint: PhysicsImpostorJoint): void;
  19364. removeJoint(joint: PhysicsImpostorJoint): void;
  19365. isSupported(): boolean;
  19366. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19367. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19368. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19369. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19370. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19371. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19372. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19373. getBodyMass(impostor: PhysicsImpostor): number;
  19374. getBodyFriction(impostor: PhysicsImpostor): number;
  19375. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19376. getBodyRestitution(impostor: PhysicsImpostor): number;
  19377. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19378. getBodyPressure?(impostor: PhysicsImpostor): number;
  19379. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  19380. getBodyStiffness?(impostor: PhysicsImpostor): number;
  19381. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  19382. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  19383. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  19384. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  19385. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  19386. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19387. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19388. sleepBody(impostor: PhysicsImpostor): void;
  19389. wakeUpBody(impostor: PhysicsImpostor): void;
  19390. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19391. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19392. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19393. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19394. getRadius(impostor: PhysicsImpostor): number;
  19395. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19396. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19397. dispose(): void;
  19398. }
  19399. /**
  19400. * Interface used to define a physics engine
  19401. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19402. */
  19403. export interface IPhysicsEngine {
  19404. /**
  19405. * Gets the gravity vector used by the simulation
  19406. */
  19407. gravity: Vector3;
  19408. /**
  19409. * Sets the gravity vector used by the simulation
  19410. * @param gravity defines the gravity vector to use
  19411. */
  19412. setGravity(gravity: Vector3): void;
  19413. /**
  19414. * Set the time step of the physics engine.
  19415. * Default is 1/60.
  19416. * To slow it down, enter 1/600 for example.
  19417. * To speed it up, 1/30
  19418. * @param newTimeStep the new timestep to apply to this world.
  19419. */
  19420. setTimeStep(newTimeStep: number): void;
  19421. /**
  19422. * Get the time step of the physics engine.
  19423. * @returns the current time step
  19424. */
  19425. getTimeStep(): number;
  19426. /**
  19427. * Release all resources
  19428. */
  19429. dispose(): void;
  19430. /**
  19431. * Gets the name of the current physics plugin
  19432. * @returns the name of the plugin
  19433. */
  19434. getPhysicsPluginName(): string;
  19435. /**
  19436. * Adding a new impostor for the impostor tracking.
  19437. * This will be done by the impostor itself.
  19438. * @param impostor the impostor to add
  19439. */
  19440. addImpostor(impostor: PhysicsImpostor): void;
  19441. /**
  19442. * Remove an impostor from the engine.
  19443. * This impostor and its mesh will not longer be updated by the physics engine.
  19444. * @param impostor the impostor to remove
  19445. */
  19446. removeImpostor(impostor: PhysicsImpostor): void;
  19447. /**
  19448. * Add a joint to the physics engine
  19449. * @param mainImpostor defines the main impostor to which the joint is added.
  19450. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19451. * @param joint defines the joint that will connect both impostors.
  19452. */
  19453. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19454. /**
  19455. * Removes a joint from the simulation
  19456. * @param mainImpostor defines the impostor used with the joint
  19457. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19458. * @param joint defines the joint to remove
  19459. */
  19460. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19461. /**
  19462. * Gets the current plugin used to run the simulation
  19463. * @returns current plugin
  19464. */
  19465. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19466. /**
  19467. * Gets the list of physic impostors
  19468. * @returns an array of PhysicsImpostor
  19469. */
  19470. getImpostors(): Array<PhysicsImpostor>;
  19471. /**
  19472. * Gets the impostor for a physics enabled object
  19473. * @param object defines the object impersonated by the impostor
  19474. * @returns the PhysicsImpostor or null if not found
  19475. */
  19476. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19477. /**
  19478. * Gets the impostor for a physics body object
  19479. * @param body defines physics body used by the impostor
  19480. * @returns the PhysicsImpostor or null if not found
  19481. */
  19482. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19483. /**
  19484. * Does a raycast in the physics world
  19485. * @param from when should the ray start?
  19486. * @param to when should the ray end?
  19487. * @returns PhysicsRaycastResult
  19488. */
  19489. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19490. /**
  19491. * Called by the scene. No need to call it.
  19492. * @param delta defines the timespam between frames
  19493. */ step(delta: number): void;
  19494. }
  19495. }
  19496. declare module BABYLON {
  19497. /**
  19498. * The interface for the physics imposter parameters
  19499. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19500. */
  19501. export interface PhysicsImpostorParameters {
  19502. /**
  19503. * The mass of the physics imposter
  19504. */
  19505. mass: number;
  19506. /**
  19507. * The friction of the physics imposter
  19508. */
  19509. friction?: number;
  19510. /**
  19511. * The coefficient of restitution of the physics imposter
  19512. */
  19513. restitution?: number;
  19514. /**
  19515. * The native options of the physics imposter
  19516. */
  19517. nativeOptions?: any;
  19518. /**
  19519. * Specifies if the parent should be ignored
  19520. */
  19521. ignoreParent?: boolean;
  19522. /**
  19523. * Specifies if bi-directional transformations should be disabled
  19524. */
  19525. disableBidirectionalTransformation?: boolean;
  19526. /**
  19527. * The pressure inside the physics imposter, soft object only
  19528. */
  19529. pressure?: number;
  19530. /**
  19531. * The stiffness the physics imposter, soft object only
  19532. */
  19533. stiffness?: number;
  19534. /**
  19535. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  19536. */
  19537. velocityIterations?: number;
  19538. /**
  19539. * The number of iterations used in maintaining consistent vertex positions, soft object only
  19540. */
  19541. positionIterations?: number;
  19542. /**
  19543. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  19544. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  19545. * Add to fix multiple points
  19546. */
  19547. fixedPoints?: number;
  19548. /**
  19549. * The collision margin around a soft object
  19550. */
  19551. margin?: number;
  19552. /**
  19553. * The collision margin around a soft object
  19554. */
  19555. damping?: number;
  19556. /**
  19557. * The path for a rope based on an extrusion
  19558. */
  19559. path?: any;
  19560. /**
  19561. * The shape of an extrusion used for a rope based on an extrusion
  19562. */
  19563. shape?: any;
  19564. }
  19565. /**
  19566. * Interface for a physics-enabled object
  19567. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19568. */
  19569. export interface IPhysicsEnabledObject {
  19570. /**
  19571. * The position of the physics-enabled object
  19572. */
  19573. position: Vector3;
  19574. /**
  19575. * The rotation of the physics-enabled object
  19576. */
  19577. rotationQuaternion: Nullable<Quaternion>;
  19578. /**
  19579. * The scale of the physics-enabled object
  19580. */
  19581. scaling: Vector3;
  19582. /**
  19583. * The rotation of the physics-enabled object
  19584. */
  19585. rotation?: Vector3;
  19586. /**
  19587. * The parent of the physics-enabled object
  19588. */
  19589. parent?: any;
  19590. /**
  19591. * The bounding info of the physics-enabled object
  19592. * @returns The bounding info of the physics-enabled object
  19593. */
  19594. getBoundingInfo(): BoundingInfo;
  19595. /**
  19596. * Computes the world matrix
  19597. * @param force Specifies if the world matrix should be computed by force
  19598. * @returns A world matrix
  19599. */
  19600. computeWorldMatrix(force: boolean): Matrix;
  19601. /**
  19602. * Gets the world matrix
  19603. * @returns A world matrix
  19604. */
  19605. getWorldMatrix?(): Matrix;
  19606. /**
  19607. * Gets the child meshes
  19608. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19609. * @returns An array of abstract meshes
  19610. */
  19611. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19612. /**
  19613. * Gets the vertex data
  19614. * @param kind The type of vertex data
  19615. * @returns A nullable array of numbers, or a float32 array
  19616. */
  19617. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19618. /**
  19619. * Gets the indices from the mesh
  19620. * @returns A nullable array of index arrays
  19621. */
  19622. getIndices?(): Nullable<IndicesArray>;
  19623. /**
  19624. * Gets the scene from the mesh
  19625. * @returns the indices array or null
  19626. */
  19627. getScene?(): Scene;
  19628. /**
  19629. * Gets the absolute position from the mesh
  19630. * @returns the absolute position
  19631. */
  19632. getAbsolutePosition(): Vector3;
  19633. /**
  19634. * Gets the absolute pivot point from the mesh
  19635. * @returns the absolute pivot point
  19636. */
  19637. getAbsolutePivotPoint(): Vector3;
  19638. /**
  19639. * Rotates the mesh
  19640. * @param axis The axis of rotation
  19641. * @param amount The amount of rotation
  19642. * @param space The space of the rotation
  19643. * @returns The rotation transform node
  19644. */
  19645. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19646. /**
  19647. * Translates the mesh
  19648. * @param axis The axis of translation
  19649. * @param distance The distance of translation
  19650. * @param space The space of the translation
  19651. * @returns The transform node
  19652. */
  19653. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19654. /**
  19655. * Sets the absolute position of the mesh
  19656. * @param absolutePosition The absolute position of the mesh
  19657. * @returns The transform node
  19658. */
  19659. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19660. /**
  19661. * Gets the class name of the mesh
  19662. * @returns The class name
  19663. */
  19664. getClassName(): string;
  19665. }
  19666. /**
  19667. * Represents a physics imposter
  19668. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19669. */
  19670. export class PhysicsImpostor {
  19671. /**
  19672. * The physics-enabled object used as the physics imposter
  19673. */
  19674. object: IPhysicsEnabledObject;
  19675. /**
  19676. * The type of the physics imposter
  19677. */
  19678. type: number;
  19679. private _options;
  19680. private _scene?;
  19681. /**
  19682. * The default object size of the imposter
  19683. */
  19684. static DEFAULT_OBJECT_SIZE: Vector3;
  19685. /**
  19686. * The identity quaternion of the imposter
  19687. */
  19688. static IDENTITY_QUATERNION: Quaternion;
  19689. /** @hidden */ pluginData: any;
  19690. private _physicsEngine;
  19691. private _physicsBody;
  19692. private _bodyUpdateRequired;
  19693. private _onBeforePhysicsStepCallbacks;
  19694. private _onAfterPhysicsStepCallbacks;
  19695. /** @hidden */ onPhysicsCollideCallbacks: Array<{
  19696. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  19697. otherImpostors: Array<PhysicsImpostor>;
  19698. }>;
  19699. private _deltaPosition;
  19700. private _deltaRotation;
  19701. private _deltaRotationConjugated;
  19702. /** hidden */ isFromLine: boolean;
  19703. private _parent;
  19704. private _isDisposed;
  19705. private static _tmpVecs;
  19706. private static _tmpQuat;
  19707. /**
  19708. * Specifies if the physics imposter is disposed
  19709. */
  19710. readonly isDisposed: boolean;
  19711. /**
  19712. * Gets the mass of the physics imposter
  19713. */
  19714. mass: number;
  19715. /**
  19716. * Gets the coefficient of friction
  19717. */
  19718. /**
  19719. * Sets the coefficient of friction
  19720. */
  19721. friction: number;
  19722. /**
  19723. * Gets the coefficient of restitution
  19724. */
  19725. /**
  19726. * Sets the coefficient of restitution
  19727. */
  19728. restitution: number;
  19729. /**
  19730. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  19731. */
  19732. /**
  19733. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  19734. */
  19735. pressure: number;
  19736. /**
  19737. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  19738. */
  19739. /**
  19740. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  19741. */
  19742. stiffness: number;
  19743. /**
  19744. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  19745. */
  19746. /**
  19747. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  19748. */
  19749. velocityIterations: number;
  19750. /**
  19751. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  19752. */
  19753. /**
  19754. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  19755. */
  19756. positionIterations: number;
  19757. /**
  19758. * The unique id of the physics imposter
  19759. * set by the physics engine when adding this impostor to the array
  19760. */
  19761. uniqueId: number;
  19762. /**
  19763. * @hidden
  19764. */
  19765. soft: boolean;
  19766. /**
  19767. * @hidden
  19768. */
  19769. segments: number;
  19770. private _joints;
  19771. /**
  19772. * Initializes the physics imposter
  19773. * @param object The physics-enabled object used as the physics imposter
  19774. * @param type The type of the physics imposter
  19775. * @param _options The options for the physics imposter
  19776. * @param _scene The Babylon scene
  19777. */
  19778. constructor(
  19779. /**
  19780. * The physics-enabled object used as the physics imposter
  19781. */
  19782. object: IPhysicsEnabledObject,
  19783. /**
  19784. * The type of the physics imposter
  19785. */
  19786. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  19787. /**
  19788. * This function will completly initialize this impostor.
  19789. * It will create a new body - but only if this mesh has no parent.
  19790. * If it has, this impostor will not be used other than to define the impostor
  19791. * of the child mesh.
  19792. * @hidden
  19793. */ init(): void;
  19794. private _getPhysicsParent;
  19795. /**
  19796. * Should a new body be generated.
  19797. * @returns boolean specifying if body initialization is required
  19798. */
  19799. isBodyInitRequired(): boolean;
  19800. /**
  19801. * Sets the updated scaling
  19802. * @param updated Specifies if the scaling is updated
  19803. */
  19804. setScalingUpdated(): void;
  19805. /**
  19806. * Force a regeneration of this or the parent's impostor's body.
  19807. * Use under cautious - This will remove all joints already implemented.
  19808. */
  19809. forceUpdate(): void;
  19810. /**
  19811. * Gets the body that holds this impostor. Either its own, or its parent.
  19812. */
  19813. /**
  19814. * Set the physics body. Used mainly by the physics engine/plugin
  19815. */
  19816. physicsBody: any;
  19817. /**
  19818. * Get the parent of the physics imposter
  19819. * @returns Physics imposter or null
  19820. */
  19821. /**
  19822. * Sets the parent of the physics imposter
  19823. */
  19824. parent: Nullable<PhysicsImpostor>;
  19825. /**
  19826. * Resets the update flags
  19827. */
  19828. resetUpdateFlags(): void;
  19829. /**
  19830. * Gets the object extend size
  19831. * @returns the object extend size
  19832. */
  19833. getObjectExtendSize(): Vector3;
  19834. /**
  19835. * Gets the object center
  19836. * @returns The object center
  19837. */
  19838. getObjectCenter(): Vector3;
  19839. /**
  19840. * Get a specific parametes from the options parameter
  19841. * @param paramName The object parameter name
  19842. * @returns The object parameter
  19843. */
  19844. getParam(paramName: string): any;
  19845. /**
  19846. * Sets a specific parameter in the options given to the physics plugin
  19847. * @param paramName The parameter name
  19848. * @param value The value of the parameter
  19849. */
  19850. setParam(paramName: string, value: number): void;
  19851. /**
  19852. * Specifically change the body's mass option. Won't recreate the physics body object
  19853. * @param mass The mass of the physics imposter
  19854. */
  19855. setMass(mass: number): void;
  19856. /**
  19857. * Gets the linear velocity
  19858. * @returns linear velocity or null
  19859. */
  19860. getLinearVelocity(): Nullable<Vector3>;
  19861. /**
  19862. * Sets the linear velocity
  19863. * @param velocity linear velocity or null
  19864. */
  19865. setLinearVelocity(velocity: Nullable<Vector3>): void;
  19866. /**
  19867. * Gets the angular velocity
  19868. * @returns angular velocity or null
  19869. */
  19870. getAngularVelocity(): Nullable<Vector3>;
  19871. /**
  19872. * Sets the angular velocity
  19873. * @param velocity The velocity or null
  19874. */
  19875. setAngularVelocity(velocity: Nullable<Vector3>): void;
  19876. /**
  19877. * Execute a function with the physics plugin native code
  19878. * Provide a function the will have two variables - the world object and the physics body object
  19879. * @param func The function to execute with the physics plugin native code
  19880. */
  19881. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  19882. /**
  19883. * Register a function that will be executed before the physics world is stepping forward
  19884. * @param func The function to execute before the physics world is stepped forward
  19885. */
  19886. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19887. /**
  19888. * Unregister a function that will be executed before the physics world is stepping forward
  19889. * @param func The function to execute before the physics world is stepped forward
  19890. */
  19891. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19892. /**
  19893. * Register a function that will be executed after the physics step
  19894. * @param func The function to execute after physics step
  19895. */
  19896. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19897. /**
  19898. * Unregisters a function that will be executed after the physics step
  19899. * @param func The function to execute after physics step
  19900. */
  19901. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19902. /**
  19903. * register a function that will be executed when this impostor collides against a different body
  19904. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  19905. * @param func Callback that is executed on collision
  19906. */
  19907. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  19908. /**
  19909. * Unregisters the physics imposter on contact
  19910. * @param collideAgainst The physics object to collide against
  19911. * @param func Callback to execute on collision
  19912. */
  19913. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  19914. private _tmpQuat;
  19915. private _tmpQuat2;
  19916. /**
  19917. * Get the parent rotation
  19918. * @returns The parent rotation
  19919. */
  19920. getParentsRotation(): Quaternion;
  19921. /**
  19922. * this function is executed by the physics engine.
  19923. */
  19924. beforeStep: () => void;
  19925. /**
  19926. * this function is executed by the physics engine
  19927. */
  19928. afterStep: () => void;
  19929. /**
  19930. * Legacy collision detection event support
  19931. */
  19932. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  19933. /**
  19934. * event and body object due to cannon's event-based architecture.
  19935. */
  19936. onCollide: (e: {
  19937. body: any;
  19938. }) => void;
  19939. /**
  19940. * Apply a force
  19941. * @param force The force to apply
  19942. * @param contactPoint The contact point for the force
  19943. * @returns The physics imposter
  19944. */
  19945. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19946. /**
  19947. * Apply an impulse
  19948. * @param force The impulse force
  19949. * @param contactPoint The contact point for the impulse force
  19950. * @returns The physics imposter
  19951. */
  19952. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19953. /**
  19954. * A help function to create a joint
  19955. * @param otherImpostor A physics imposter used to create a joint
  19956. * @param jointType The type of joint
  19957. * @param jointData The data for the joint
  19958. * @returns The physics imposter
  19959. */
  19960. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  19961. /**
  19962. * Add a joint to this impostor with a different impostor
  19963. * @param otherImpostor A physics imposter used to add a joint
  19964. * @param joint The joint to add
  19965. * @returns The physics imposter
  19966. */
  19967. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  19968. /**
  19969. * Add an anchor to a cloth impostor
  19970. * @param otherImpostor rigid impostor to anchor to
  19971. * @param width ratio across width from 0 to 1
  19972. * @param height ratio up height from 0 to 1
  19973. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  19974. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  19975. * @returns impostor the soft imposter
  19976. */
  19977. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  19978. /**
  19979. * Add a hook to a rope impostor
  19980. * @param otherImpostor rigid impostor to anchor to
  19981. * @param length ratio across rope from 0 to 1
  19982. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  19983. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  19984. * @returns impostor the rope imposter
  19985. */
  19986. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  19987. /**
  19988. * Will keep this body still, in a sleep mode.
  19989. * @returns the physics imposter
  19990. */
  19991. sleep(): PhysicsImpostor;
  19992. /**
  19993. * Wake the body up.
  19994. * @returns The physics imposter
  19995. */
  19996. wakeUp(): PhysicsImpostor;
  19997. /**
  19998. * Clones the physics imposter
  19999. * @param newObject The physics imposter clones to this physics-enabled object
  20000. * @returns A nullable physics imposter
  20001. */
  20002. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20003. /**
  20004. * Disposes the physics imposter
  20005. */
  20006. dispose(): void;
  20007. /**
  20008. * Sets the delta position
  20009. * @param position The delta position amount
  20010. */
  20011. setDeltaPosition(position: Vector3): void;
  20012. /**
  20013. * Sets the delta rotation
  20014. * @param rotation The delta rotation amount
  20015. */
  20016. setDeltaRotation(rotation: Quaternion): void;
  20017. /**
  20018. * Gets the box size of the physics imposter and stores the result in the input parameter
  20019. * @param result Stores the box size
  20020. * @returns The physics imposter
  20021. */
  20022. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20023. /**
  20024. * Gets the radius of the physics imposter
  20025. * @returns Radius of the physics imposter
  20026. */
  20027. getRadius(): number;
  20028. /**
  20029. * Sync a bone with this impostor
  20030. * @param bone The bone to sync to the impostor.
  20031. * @param boneMesh The mesh that the bone is influencing.
  20032. * @param jointPivot The pivot of the joint / bone in local space.
  20033. * @param distToJoint Optional distance from the impostor to the joint.
  20034. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20035. */
  20036. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20037. /**
  20038. * Sync impostor to a bone
  20039. * @param bone The bone that the impostor will be synced to.
  20040. * @param boneMesh The mesh that the bone is influencing.
  20041. * @param jointPivot The pivot of the joint / bone in local space.
  20042. * @param distToJoint Optional distance from the impostor to the joint.
  20043. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20044. * @param boneAxis Optional vector3 axis the bone is aligned with
  20045. */
  20046. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20047. /**
  20048. * No-Imposter type
  20049. */
  20050. static NoImpostor: number;
  20051. /**
  20052. * Sphere-Imposter type
  20053. */
  20054. static SphereImpostor: number;
  20055. /**
  20056. * Box-Imposter type
  20057. */
  20058. static BoxImpostor: number;
  20059. /**
  20060. * Plane-Imposter type
  20061. */
  20062. static PlaneImpostor: number;
  20063. /**
  20064. * Mesh-imposter type
  20065. */
  20066. static MeshImpostor: number;
  20067. /**
  20068. * Cylinder-Imposter type
  20069. */
  20070. static CylinderImpostor: number;
  20071. /**
  20072. * Particle-Imposter type
  20073. */
  20074. static ParticleImpostor: number;
  20075. /**
  20076. * Heightmap-Imposter type
  20077. */
  20078. static HeightmapImpostor: number;
  20079. /**
  20080. * ConvexHull-Impostor type (Ammo.js plugin only)
  20081. */
  20082. static ConvexHullImpostor: number;
  20083. /**
  20084. * Rope-Imposter type
  20085. */
  20086. static RopeImpostor: number;
  20087. /**
  20088. * Cloth-Imposter type
  20089. */
  20090. static ClothImpostor: number;
  20091. /**
  20092. * Softbody-Imposter type
  20093. */
  20094. static SoftbodyImpostor: number;
  20095. }
  20096. }
  20097. declare module BABYLON {
  20098. /**
  20099. * Class used to represent a specific level of detail of a mesh
  20100. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20101. */
  20102. export class MeshLODLevel {
  20103. /** Defines the distance where this level should star being displayed */
  20104. distance: number;
  20105. /** Defines the mesh to use to render this level */
  20106. mesh: Nullable<Mesh>;
  20107. /**
  20108. * Creates a new LOD level
  20109. * @param distance defines the distance where this level should star being displayed
  20110. * @param mesh defines the mesh to use to render this level
  20111. */
  20112. constructor(
  20113. /** Defines the distance where this level should star being displayed */
  20114. distance: number,
  20115. /** Defines the mesh to use to render this level */
  20116. mesh: Nullable<Mesh>);
  20117. }
  20118. /**
  20119. * @hidden
  20120. **/
  20121. export class _CreationDataStorage {
  20122. closePath?: boolean;
  20123. closeArray?: boolean;
  20124. idx: number[];
  20125. dashSize: number;
  20126. gapSize: number;
  20127. path3D: Path3D;
  20128. pathArray: Vector3[][];
  20129. arc: number;
  20130. radius: number;
  20131. cap: number;
  20132. tessellation: number;
  20133. }
  20134. /**
  20135. * @hidden
  20136. **/ private class _InstanceDataStorage {
  20137. visibleInstances: any;
  20138. batchCache: _InstancesBatch;
  20139. instancesBufferSize: number;
  20140. instancesBuffer: Nullable<Buffer>;
  20141. instancesData: Float32Array;
  20142. overridenInstanceCount: number;
  20143. isFrozen: boolean; previousBatch: _InstancesBatch;
  20144. hardwareInstancedRendering: boolean;
  20145. }
  20146. /**
  20147. * @hidden
  20148. **/
  20149. export class _InstancesBatch {
  20150. mustReturn: boolean;
  20151. visibleInstances: Nullable<InstancedMesh[]>[];
  20152. renderSelf: boolean[];
  20153. hardwareInstancedRendering: boolean[];
  20154. }
  20155. /**
  20156. * Class used to represent renderable models
  20157. */
  20158. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20159. /**
  20160. * Mesh side orientation : usually the external or front surface
  20161. */
  20162. static readonly FRONTSIDE: number;
  20163. /**
  20164. * Mesh side orientation : usually the internal or back surface
  20165. */
  20166. static readonly BACKSIDE: number;
  20167. /**
  20168. * Mesh side orientation : both internal and external or front and back surfaces
  20169. */
  20170. static readonly DOUBLESIDE: number;
  20171. /**
  20172. * Mesh side orientation : by default, `FRONTSIDE`
  20173. */
  20174. static readonly DEFAULTSIDE: number;
  20175. /**
  20176. * Mesh cap setting : no cap
  20177. */
  20178. static readonly NO_CAP: number;
  20179. /**
  20180. * Mesh cap setting : one cap at the beginning of the mesh
  20181. */
  20182. static readonly CAP_START: number;
  20183. /**
  20184. * Mesh cap setting : one cap at the end of the mesh
  20185. */
  20186. static readonly CAP_END: number;
  20187. /**
  20188. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20189. */
  20190. static readonly CAP_ALL: number;
  20191. /**
  20192. * Gets the default side orientation.
  20193. * @param orientation the orientation to value to attempt to get
  20194. * @returns the default orientation
  20195. * @hidden
  20196. */ private static _GetDefaultSideOrientation(orientation?: number): number;
  20197. private _onBeforeRenderObservable;
  20198. private _onBeforeBindObservable;
  20199. private _onAfterRenderObservable;
  20200. private _onBeforeDrawObservable;
  20201. /**
  20202. * An event triggered before rendering the mesh
  20203. */
  20204. readonly onBeforeRenderObservable: Observable<Mesh>;
  20205. /**
  20206. * An event triggered before binding the mesh
  20207. */
  20208. readonly onBeforeBindObservable: Observable<Mesh>;
  20209. /**
  20210. * An event triggered after rendering the mesh
  20211. */
  20212. readonly onAfterRenderObservable: Observable<Mesh>;
  20213. /**
  20214. * An event triggered before drawing the mesh
  20215. */
  20216. readonly onBeforeDrawObservable: Observable<Mesh>;
  20217. private _onBeforeDrawObserver;
  20218. /**
  20219. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20220. */
  20221. onBeforeDraw: () => void;
  20222. /**
  20223. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20224. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20225. */
  20226. delayLoadState: number;
  20227. /**
  20228. * Gets the list of instances created from this mesh
  20229. * it is not supposed to be modified manually.
  20230. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20231. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20232. */
  20233. instances: InstancedMesh[];
  20234. /**
  20235. * Gets the file containing delay loading data for this mesh
  20236. */
  20237. delayLoadingFile: string;
  20238. /** @hidden */ binaryInfo: any;
  20239. private _LODLevels;
  20240. /**
  20241. * User defined function used to change how LOD level selection is done
  20242. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20243. */
  20244. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20245. private _morphTargetManager;
  20246. /**
  20247. * Gets or sets the morph target manager
  20248. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20249. */
  20250. morphTargetManager: Nullable<MorphTargetManager>;
  20251. /** @hidden */ creationDataStorage: Nullable<_CreationDataStorage>;
  20252. /** @hidden */ geometry: Nullable<Geometry>;
  20253. /** @hidden */ delayInfo: Array<string>;
  20254. /** @hidden */ delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20255. /** @hidden */ instanceDataStorage: _InstanceDataStorage;
  20256. private _effectiveMaterial;
  20257. /** @hidden */ shouldGenerateFlatShading: boolean;
  20258. private _preActivateId;
  20259. /** @hidden */ originalBuilderSideOrientation: number;
  20260. /**
  20261. * Use this property to change the original side orientation defined at construction time
  20262. */
  20263. overrideMaterialSideOrientation: Nullable<number>;
  20264. private _areNormalsFrozen;
  20265. private _sourcePositions;
  20266. private _sourceNormals;
  20267. private _source;
  20268. private meshMap;
  20269. /**
  20270. * Gets the source mesh (the one used to clone this one from)
  20271. */
  20272. readonly source: Nullable<Mesh>;
  20273. /**
  20274. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20275. */
  20276. isUnIndexed: boolean;
  20277. /**
  20278. * @constructor
  20279. * @param name The value used by scene.getMeshByName() to do a lookup.
  20280. * @param scene The scene to add this mesh to.
  20281. * @param parent The parent of this mesh, if it has one
  20282. * @param source An optional Mesh from which geometry is shared, cloned.
  20283. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20284. * When false, achieved by calling a clone(), also passing False.
  20285. * This will make creation of children, recursive.
  20286. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20287. */
  20288. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20289. /**
  20290. * Gets the class name
  20291. * @returns the string "Mesh".
  20292. */
  20293. getClassName(): string;
  20294. /** @hidden */ protected readonly _isMesh: boolean;
  20295. /**
  20296. * Returns a description of this mesh
  20297. * @param fullDetails define if full details about this mesh must be used
  20298. * @returns a descriptive string representing this mesh
  20299. */
  20300. toString(fullDetails?: boolean): string;
  20301. /** @hidden */ unBindEffect(): void;
  20302. /**
  20303. * Gets a boolean indicating if this mesh has LOD
  20304. */
  20305. readonly hasLODLevels: boolean;
  20306. /**
  20307. * Gets the list of MeshLODLevel associated with the current mesh
  20308. * @returns an array of MeshLODLevel
  20309. */
  20310. getLODLevels(): MeshLODLevel[];
  20311. private _sortLODLevels;
  20312. /**
  20313. * Add a mesh as LOD level triggered at the given distance.
  20314. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20315. * @param distance The distance from the center of the object to show this level
  20316. * @param mesh The mesh to be added as LOD level (can be null)
  20317. * @return This mesh (for chaining)
  20318. */
  20319. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20320. /**
  20321. * Returns the LOD level mesh at the passed distance or null if not found.
  20322. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20323. * @param distance The distance from the center of the object to show this level
  20324. * @returns a Mesh or `null`
  20325. */
  20326. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20327. /**
  20328. * Remove a mesh from the LOD array
  20329. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20330. * @param mesh defines the mesh to be removed
  20331. * @return This mesh (for chaining)
  20332. */
  20333. removeLODLevel(mesh: Mesh): Mesh;
  20334. /**
  20335. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20336. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20337. * @param camera defines the camera to use to compute distance
  20338. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20339. * @return This mesh (for chaining)
  20340. */
  20341. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20342. /**
  20343. * Gets the mesh internal Geometry object
  20344. */
  20345. readonly geometry: Nullable<Geometry>;
  20346. /**
  20347. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20348. * @returns the total number of vertices
  20349. */
  20350. getTotalVertices(): number;
  20351. /**
  20352. * Returns the content of an associated vertex buffer
  20353. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20354. * - VertexBuffer.PositionKind
  20355. * - VertexBuffer.UVKind
  20356. * - VertexBuffer.UV2Kind
  20357. * - VertexBuffer.UV3Kind
  20358. * - VertexBuffer.UV4Kind
  20359. * - VertexBuffer.UV5Kind
  20360. * - VertexBuffer.UV6Kind
  20361. * - VertexBuffer.ColorKind
  20362. * - VertexBuffer.MatricesIndicesKind
  20363. * - VertexBuffer.MatricesIndicesExtraKind
  20364. * - VertexBuffer.MatricesWeightsKind
  20365. * - VertexBuffer.MatricesWeightsExtraKind
  20366. * @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
  20367. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20368. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20369. */
  20370. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20371. /**
  20372. * Returns the mesh VertexBuffer object from the requested `kind`
  20373. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20374. * - VertexBuffer.PositionKind
  20375. * - VertexBuffer.UVKind
  20376. * - VertexBuffer.UV2Kind
  20377. * - VertexBuffer.UV3Kind
  20378. * - VertexBuffer.UV4Kind
  20379. * - VertexBuffer.UV5Kind
  20380. * - VertexBuffer.UV6Kind
  20381. * - VertexBuffer.ColorKind
  20382. * - VertexBuffer.MatricesIndicesKind
  20383. * - VertexBuffer.MatricesIndicesExtraKind
  20384. * - VertexBuffer.MatricesWeightsKind
  20385. * - VertexBuffer.MatricesWeightsExtraKind
  20386. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20387. */
  20388. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20389. /**
  20390. * Tests if a specific vertex buffer is associated with this mesh
  20391. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20392. * - VertexBuffer.PositionKind
  20393. * - VertexBuffer.UVKind
  20394. * - VertexBuffer.UV2Kind
  20395. * - VertexBuffer.UV3Kind
  20396. * - VertexBuffer.UV4Kind
  20397. * - VertexBuffer.UV5Kind
  20398. * - VertexBuffer.UV6Kind
  20399. * - VertexBuffer.ColorKind
  20400. * - VertexBuffer.MatricesIndicesKind
  20401. * - VertexBuffer.MatricesIndicesExtraKind
  20402. * - VertexBuffer.MatricesWeightsKind
  20403. * - VertexBuffer.MatricesWeightsExtraKind
  20404. * @returns a boolean
  20405. */
  20406. isVerticesDataPresent(kind: string): boolean;
  20407. /**
  20408. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20409. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20410. * - VertexBuffer.PositionKind
  20411. * - VertexBuffer.UVKind
  20412. * - VertexBuffer.UV2Kind
  20413. * - VertexBuffer.UV3Kind
  20414. * - VertexBuffer.UV4Kind
  20415. * - VertexBuffer.UV5Kind
  20416. * - VertexBuffer.UV6Kind
  20417. * - VertexBuffer.ColorKind
  20418. * - VertexBuffer.MatricesIndicesKind
  20419. * - VertexBuffer.MatricesIndicesExtraKind
  20420. * - VertexBuffer.MatricesWeightsKind
  20421. * - VertexBuffer.MatricesWeightsExtraKind
  20422. * @returns a boolean
  20423. */
  20424. isVertexBufferUpdatable(kind: string): boolean;
  20425. /**
  20426. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20427. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20428. * - VertexBuffer.PositionKind
  20429. * - VertexBuffer.UVKind
  20430. * - VertexBuffer.UV2Kind
  20431. * - VertexBuffer.UV3Kind
  20432. * - VertexBuffer.UV4Kind
  20433. * - VertexBuffer.UV5Kind
  20434. * - VertexBuffer.UV6Kind
  20435. * - VertexBuffer.ColorKind
  20436. * - VertexBuffer.MatricesIndicesKind
  20437. * - VertexBuffer.MatricesIndicesExtraKind
  20438. * - VertexBuffer.MatricesWeightsKind
  20439. * - VertexBuffer.MatricesWeightsExtraKind
  20440. * @returns an array of strings
  20441. */
  20442. getVerticesDataKinds(): string[];
  20443. /**
  20444. * Returns a positive integer : the total number of indices in this mesh geometry.
  20445. * @returns the numner of indices or zero if the mesh has no geometry.
  20446. */
  20447. getTotalIndices(): number;
  20448. /**
  20449. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20450. * @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.
  20451. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20452. * @returns the indices array or an empty array if the mesh has no geometry
  20453. */
  20454. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20455. readonly isBlocked: boolean;
  20456. /**
  20457. * Determine if the current mesh is ready to be rendered
  20458. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20459. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20460. * @returns true if all associated assets are ready (material, textures, shaders)
  20461. */
  20462. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20463. /**
  20464. * 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.
  20465. */
  20466. readonly areNormalsFrozen: boolean;
  20467. /**
  20468. * 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.
  20469. * @returns the current mesh
  20470. */
  20471. freezeNormals(): Mesh;
  20472. /**
  20473. * 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
  20474. * @returns the current mesh
  20475. */
  20476. unfreezeNormals(): Mesh;
  20477. /**
  20478. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20479. */
  20480. overridenInstanceCount: number;
  20481. /** @hidden */ preActivate(): Mesh;
  20482. /** @hidden */ preActivateForIntermediateRendering(renderId: number): Mesh;
  20483. /** @hidden */ registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20484. /**
  20485. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20486. * This means the mesh underlying bounding box and sphere are recomputed.
  20487. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20488. * @returns the current mesh
  20489. */
  20490. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20491. /** @hidden */ createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20492. /**
  20493. * This function will subdivide the mesh into multiple submeshes
  20494. * @param count defines the expected number of submeshes
  20495. */
  20496. subdivide(count: number): void;
  20497. /**
  20498. * Copy a FloatArray into a specific associated vertex buffer
  20499. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20500. * - VertexBuffer.PositionKind
  20501. * - VertexBuffer.UVKind
  20502. * - VertexBuffer.UV2Kind
  20503. * - VertexBuffer.UV3Kind
  20504. * - VertexBuffer.UV4Kind
  20505. * - VertexBuffer.UV5Kind
  20506. * - VertexBuffer.UV6Kind
  20507. * - VertexBuffer.ColorKind
  20508. * - VertexBuffer.MatricesIndicesKind
  20509. * - VertexBuffer.MatricesIndicesExtraKind
  20510. * - VertexBuffer.MatricesWeightsKind
  20511. * - VertexBuffer.MatricesWeightsExtraKind
  20512. * @param data defines the data source
  20513. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20514. * @param stride defines the data stride size (can be null)
  20515. * @returns the current mesh
  20516. */
  20517. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20518. /**
  20519. * Flags an associated vertex buffer as updatable
  20520. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20521. * - VertexBuffer.PositionKind
  20522. * - VertexBuffer.UVKind
  20523. * - VertexBuffer.UV2Kind
  20524. * - VertexBuffer.UV3Kind
  20525. * - VertexBuffer.UV4Kind
  20526. * - VertexBuffer.UV5Kind
  20527. * - VertexBuffer.UV6Kind
  20528. * - VertexBuffer.ColorKind
  20529. * - VertexBuffer.MatricesIndicesKind
  20530. * - VertexBuffer.MatricesIndicesExtraKind
  20531. * - VertexBuffer.MatricesWeightsKind
  20532. * - VertexBuffer.MatricesWeightsExtraKind
  20533. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20534. */
  20535. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20536. /**
  20537. * Sets the mesh global Vertex Buffer
  20538. * @param buffer defines the buffer to use
  20539. * @returns the current mesh
  20540. */
  20541. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20542. /**
  20543. * Update a specific associated vertex buffer
  20544. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20545. * - VertexBuffer.PositionKind
  20546. * - VertexBuffer.UVKind
  20547. * - VertexBuffer.UV2Kind
  20548. * - VertexBuffer.UV3Kind
  20549. * - VertexBuffer.UV4Kind
  20550. * - VertexBuffer.UV5Kind
  20551. * - VertexBuffer.UV6Kind
  20552. * - VertexBuffer.ColorKind
  20553. * - VertexBuffer.MatricesIndicesKind
  20554. * - VertexBuffer.MatricesIndicesExtraKind
  20555. * - VertexBuffer.MatricesWeightsKind
  20556. * - VertexBuffer.MatricesWeightsExtraKind
  20557. * @param data defines the data source
  20558. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20559. * @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)
  20560. * @returns the current mesh
  20561. */
  20562. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20563. /**
  20564. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20565. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20566. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20567. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20568. * @returns the current mesh
  20569. */
  20570. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20571. /**
  20572. * Creates a un-shared specific occurence of the geometry for the mesh.
  20573. * @returns the current mesh
  20574. */
  20575. makeGeometryUnique(): Mesh;
  20576. /**
  20577. * Set the index buffer of this mesh
  20578. * @param indices defines the source data
  20579. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20580. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20581. * @returns the current mesh
  20582. */
  20583. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20584. /**
  20585. * Update the current index buffer
  20586. * @param indices defines the source data
  20587. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20588. * @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)
  20589. * @returns the current mesh
  20590. */
  20591. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  20592. /**
  20593. * Invert the geometry to move from a right handed system to a left handed one.
  20594. * @returns the current mesh
  20595. */
  20596. toLeftHanded(): Mesh;
  20597. /** @hidden */ bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20598. /** @hidden */ draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20599. /**
  20600. * Registers for this mesh a javascript function called just before the rendering process
  20601. * @param func defines the function to call before rendering this mesh
  20602. * @returns the current mesh
  20603. */
  20604. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20605. /**
  20606. * Disposes a previously registered javascript function called before the rendering
  20607. * @param func defines the function to remove
  20608. * @returns the current mesh
  20609. */
  20610. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20611. /**
  20612. * Registers for this mesh a javascript function called just after the rendering is complete
  20613. * @param func defines the function to call after rendering this mesh
  20614. * @returns the current mesh
  20615. */
  20616. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20617. /**
  20618. * Disposes a previously registered javascript function called after the rendering.
  20619. * @param func defines the function to remove
  20620. * @returns the current mesh
  20621. */
  20622. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20623. /** @hidden */ getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20624. /** @hidden */ renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20625. /** @hidden */ processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20626. /** @hidden */ freeze(): void;
  20627. /** @hidden */ unFreeze(): void;
  20628. /**
  20629. * 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
  20630. * @param subMesh defines the subMesh to render
  20631. * @param enableAlphaMode defines if alpha mode can be changed
  20632. * @returns the current mesh
  20633. */
  20634. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20635. private _onBeforeDraw;
  20636. /**
  20637. * Renormalize the mesh and patch it up if there are no weights
  20638. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20639. * However in the case of zero weights then we set just a single influence to 1.
  20640. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20641. */
  20642. cleanMatrixWeights(): void;
  20643. private normalizeSkinFourWeights;
  20644. private normalizeSkinWeightsAndExtra;
  20645. /**
  20646. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  20647. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  20648. * the user know there was an issue with importing the mesh
  20649. * @returns a validation object with skinned, valid and report string
  20650. */
  20651. validateSkinning(): {
  20652. skinned: boolean;
  20653. valid: boolean;
  20654. report: string;
  20655. };
  20656. /** @hidden */ checkDelayState(): Mesh;
  20657. private _queueLoad;
  20658. /**
  20659. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20660. * A mesh is in the frustum if its bounding box intersects the frustum
  20661. * @param frustumPlanes defines the frustum to test
  20662. * @returns true if the mesh is in the frustum planes
  20663. */
  20664. isInFrustum(frustumPlanes: Plane[]): boolean;
  20665. /**
  20666. * Sets the mesh material by the material or multiMaterial `id` property
  20667. * @param id is a string identifying the material or the multiMaterial
  20668. * @returns the current mesh
  20669. */
  20670. setMaterialByID(id: string): Mesh;
  20671. /**
  20672. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20673. * @returns an array of IAnimatable
  20674. */
  20675. getAnimatables(): IAnimatable[];
  20676. /**
  20677. * Modifies the mesh geometry according to the passed transformation matrix.
  20678. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20679. * The mesh normals are modified using the same transformation.
  20680. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20681. * @param transform defines the transform matrix to use
  20682. * @see http://doc.babylonjs.com/resources/baking_transformations
  20683. * @returns the current mesh
  20684. */
  20685. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20686. /**
  20687. * Modifies the mesh geometry according to its own current World Matrix.
  20688. * The mesh World Matrix is then reset.
  20689. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20690. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20691. * @see http://doc.babylonjs.com/resources/baking_transformations
  20692. * @returns the current mesh
  20693. */
  20694. bakeCurrentTransformIntoVertices(): Mesh;
  20695. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  20696. /** @hidden */ resetPointsArrayCache(): Mesh;
  20697. /** @hidden */ generatePointsArray(): boolean;
  20698. /**
  20699. * Returns a new Mesh object generated from the current mesh properties.
  20700. * This method must not get confused with createInstance()
  20701. * @param name is a string, the name given to the new mesh
  20702. * @param newParent can be any Node object (default `null`)
  20703. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  20704. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  20705. * @returns a new mesh
  20706. */
  20707. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  20708. /**
  20709. * Releases resources associated with this mesh.
  20710. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20711. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20712. */
  20713. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20714. /**
  20715. * Modifies the mesh geometry according to a displacement map.
  20716. * 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.
  20717. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20718. * @param url is a string, the URL from the image file is to be downloaded.
  20719. * @param minHeight is the lower limit of the displacement.
  20720. * @param maxHeight is the upper limit of the displacement.
  20721. * @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.
  20722. * @param uvOffset is an optional vector2 used to offset UV.
  20723. * @param uvScale is an optional vector2 used to scale UV.
  20724. * @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.
  20725. * @returns the Mesh.
  20726. */
  20727. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20728. /**
  20729. * Modifies the mesh geometry according to a displacementMap buffer.
  20730. * 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.
  20731. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20732. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  20733. * @param heightMapWidth is the width of the buffer image.
  20734. * @param heightMapHeight is the height of the buffer image.
  20735. * @param minHeight is the lower limit of the displacement.
  20736. * @param maxHeight is the upper limit of the displacement.
  20737. * @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.
  20738. * @param uvOffset is an optional vector2 used to offset UV.
  20739. * @param uvScale is an optional vector2 used to scale UV.
  20740. * @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.
  20741. * @returns the Mesh.
  20742. */
  20743. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20744. /**
  20745. * Modify the mesh to get a flat shading rendering.
  20746. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  20747. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  20748. * @returns current mesh
  20749. */
  20750. convertToFlatShadedMesh(): Mesh;
  20751. /**
  20752. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  20753. * In other words, more vertices, no more indices and a single bigger VBO.
  20754. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  20755. * @returns current mesh
  20756. */
  20757. convertToUnIndexedMesh(): Mesh;
  20758. /**
  20759. * Inverses facet orientations.
  20760. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  20761. * @param flipNormals will also inverts the normals
  20762. * @returns current mesh
  20763. */
  20764. flipFaces(flipNormals?: boolean): Mesh;
  20765. /**
  20766. * Increase the number of facets and hence vertices in a mesh
  20767. * Vertex normals are interpolated from existing vertex normals
  20768. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  20769. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  20770. */
  20771. increaseVertices(numberPerEdge: number): void;
  20772. /**
  20773. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  20774. * This will undo any application of covertToFlatShadedMesh
  20775. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  20776. */
  20777. forceSharedVertices(): void;
  20778. /** @hidden */ private static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  20779. /** @hidden */ private static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  20780. /**
  20781. * Creates a new InstancedMesh object from the mesh model.
  20782. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20783. * @param name defines the name of the new instance
  20784. * @returns a new InstancedMesh
  20785. */
  20786. createInstance(name: string): InstancedMesh;
  20787. /**
  20788. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  20789. * After this call, all the mesh instances have the same submeshes than the current mesh.
  20790. * @returns the current mesh
  20791. */
  20792. synchronizeInstances(): Mesh;
  20793. /**
  20794. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  20795. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  20796. * This should be used together with the simplification to avoid disappearing triangles.
  20797. * @param successCallback an optional success callback to be called after the optimization finished.
  20798. * @returns the current mesh
  20799. */
  20800. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  20801. /**
  20802. * Serialize current mesh
  20803. * @param serializationObject defines the object which will receive the serialization data
  20804. */
  20805. serialize(serializationObject: any): void;
  20806. /** @hidden */ syncGeometryWithMorphTargetManager(): void;
  20807. /** @hidden */ private static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  20808. /**
  20809. * Returns a new Mesh object parsed from the source provided.
  20810. * @param parsedMesh is the source
  20811. * @param scene defines the hosting scene
  20812. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  20813. * @returns a new Mesh
  20814. */
  20815. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  20816. /**
  20817. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  20818. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20819. * @param name defines the name of the mesh to create
  20820. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  20821. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  20822. * @param closePath creates a seam between the first and the last points of each path of the path array
  20823. * @param offset is taken in account only if the `pathArray` is containing a single path
  20824. * @param scene defines the hosting scene
  20825. * @param updatable defines if the mesh must be flagged as updatable
  20826. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20827. * @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)
  20828. * @returns a new Mesh
  20829. */
  20830. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20831. /**
  20832. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  20833. * @param name defines the name of the mesh to create
  20834. * @param radius sets the radius size (float) of the polygon (default 0.5)
  20835. * @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
  20836. * @param scene defines the hosting scene
  20837. * @param updatable defines if the mesh must be flagged as updatable
  20838. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20839. * @returns a new Mesh
  20840. */
  20841. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20842. /**
  20843. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  20844. * @param name defines the name of the mesh to create
  20845. * @param size sets the size (float) of each box side (default 1)
  20846. * @param scene defines the hosting scene
  20847. * @param updatable defines if the mesh must be flagged as updatable
  20848. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20849. * @returns a new Mesh
  20850. */
  20851. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20852. /**
  20853. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  20854. * @param name defines the name of the mesh to create
  20855. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  20856. * @param diameter sets the diameter size (float) of the sphere (default 1)
  20857. * @param scene defines the hosting scene
  20858. * @param updatable defines if the mesh must be flagged as updatable
  20859. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20860. * @returns a new Mesh
  20861. */
  20862. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20863. /**
  20864. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  20865. * @param name defines the name of the mesh to create
  20866. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  20867. * @param diameter sets the diameter size (float) of the sphere (default 1)
  20868. * @param scene defines the hosting scene
  20869. * @returns a new Mesh
  20870. */
  20871. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  20872. /**
  20873. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  20874. * @param name defines the name of the mesh to create
  20875. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  20876. * @param diameterTop set the top cap diameter (floats, default 1)
  20877. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  20878. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  20879. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  20880. * @param scene defines the hosting scene
  20881. * @param updatable defines if the mesh must be flagged as updatable
  20882. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20883. * @returns a new Mesh
  20884. */
  20885. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  20886. /**
  20887. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  20888. * @param name defines the name of the mesh to create
  20889. * @param diameter sets the diameter size (float) of the torus (default 1)
  20890. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  20891. * @param tessellation sets the number of torus sides (postive integer, default 16)
  20892. * @param scene defines the hosting scene
  20893. * @param updatable defines if the mesh must be flagged as updatable
  20894. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20895. * @returns a new Mesh
  20896. */
  20897. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20898. /**
  20899. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  20900. * @param name defines the name of the mesh to create
  20901. * @param radius sets the global radius size (float) of the torus knot (default 2)
  20902. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  20903. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  20904. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  20905. * @param p the number of windings on X axis (positive integers, default 2)
  20906. * @param q the number of windings on Y axis (positive integers, default 3)
  20907. * @param scene defines the hosting scene
  20908. * @param updatable defines if the mesh must be flagged as updatable
  20909. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20910. * @returns a new Mesh
  20911. */
  20912. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20913. /**
  20914. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  20915. * @param name defines the name of the mesh to create
  20916. * @param points is an array successive Vector3
  20917. * @param scene defines the hosting scene
  20918. * @param updatable defines if the mesh must be flagged as updatable
  20919. * @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).
  20920. * @returns a new Mesh
  20921. */
  20922. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  20923. /**
  20924. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  20925. * @param name defines the name of the mesh to create
  20926. * @param points is an array successive Vector3
  20927. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  20928. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  20929. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  20930. * @param scene defines the hosting scene
  20931. * @param updatable defines if the mesh must be flagged as updatable
  20932. * @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)
  20933. * @returns a new Mesh
  20934. */
  20935. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  20936. /**
  20937. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  20938. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  20939. * 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.
  20940. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20941. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20942. * Remember you can only change the shape positions, not their number when updating a polygon.
  20943. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  20944. * @param name defines the name of the mesh to create
  20945. * @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
  20946. * @param scene defines the hosting scene
  20947. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  20948. * @param updatable defines if the mesh must be flagged as updatable
  20949. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20950. * @param earcutInjection can be used to inject your own earcut reference
  20951. * @returns a new Mesh
  20952. */
  20953. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  20954. /**
  20955. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  20956. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  20957. * @param name defines the name of the mesh to create
  20958. * @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
  20959. * @param depth defines the height of extrusion
  20960. * @param scene defines the hosting scene
  20961. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  20962. * @param updatable defines if the mesh must be flagged as updatable
  20963. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20964. * @param earcutInjection can be used to inject your own earcut reference
  20965. * @returns a new Mesh
  20966. */
  20967. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  20968. /**
  20969. * Creates an extruded shape mesh.
  20970. * 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
  20971. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20972. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20973. * @param name defines the name of the mesh to create
  20974. * @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
  20975. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  20976. * @param scale is the value to scale the shape
  20977. * @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
  20978. * @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
  20979. * @param scene defines the hosting scene
  20980. * @param updatable defines if the mesh must be flagged as updatable
  20981. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20982. * @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)
  20983. * @returns a new Mesh
  20984. */
  20985. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20986. /**
  20987. * Creates an custom extruded shape mesh.
  20988. * The custom extrusion is a parametric shape.
  20989. * It has no predefined shape. Its final shape will depend on the input parameters.
  20990. * Please consider using the same method from the MeshBuilder class instead
  20991. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20992. * @param name defines the name of the mesh to create
  20993. * @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
  20994. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  20995. * @param scaleFunction is a custom Javascript function called on each path point
  20996. * @param rotationFunction is a custom Javascript function called on each path point
  20997. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  20998. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  20999. * @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
  21000. * @param scene defines the hosting scene
  21001. * @param updatable defines if the mesh must be flagged as updatable
  21002. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21003. * @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)
  21004. * @returns a new Mesh
  21005. */
  21006. 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;
  21007. /**
  21008. * Creates lathe mesh.
  21009. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21010. * Please consider using the same method from the MeshBuilder class instead
  21011. * @param name defines the name of the mesh to create
  21012. * @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
  21013. * @param radius is the radius value of the lathe
  21014. * @param tessellation is the side number of the lathe.
  21015. * @param scene defines the hosting scene
  21016. * @param updatable defines if the mesh must be flagged as updatable
  21017. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21018. * @returns a new Mesh
  21019. */
  21020. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21021. /**
  21022. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21023. * @param name defines the name of the mesh to create
  21024. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21025. * @param scene defines the hosting scene
  21026. * @param updatable defines if the mesh must be flagged as updatable
  21027. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21028. * @returns a new Mesh
  21029. */
  21030. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21031. /**
  21032. * Creates a ground mesh.
  21033. * Please consider using the same method from the MeshBuilder class instead
  21034. * @param name defines the name of the mesh to create
  21035. * @param width set the width of the ground
  21036. * @param height set the height of the ground
  21037. * @param subdivisions sets the number of subdivisions per side
  21038. * @param scene defines the hosting scene
  21039. * @param updatable defines if the mesh must be flagged as updatable
  21040. * @returns a new Mesh
  21041. */
  21042. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21043. /**
  21044. * Creates a tiled ground mesh.
  21045. * Please consider using the same method from the MeshBuilder class instead
  21046. * @param name defines the name of the mesh to create
  21047. * @param xmin set the ground minimum X coordinate
  21048. * @param zmin set the ground minimum Y coordinate
  21049. * @param xmax set the ground maximum X coordinate
  21050. * @param zmax set the ground maximum Z coordinate
  21051. * @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
  21052. * @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
  21053. * @param scene defines the hosting scene
  21054. * @param updatable defines if the mesh must be flagged as updatable
  21055. * @returns a new Mesh
  21056. */
  21057. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21058. w: number;
  21059. h: number;
  21060. }, precision: {
  21061. w: number;
  21062. h: number;
  21063. }, scene: Scene, updatable?: boolean): Mesh;
  21064. /**
  21065. * Creates a ground mesh from a height map.
  21066. * Please consider using the same method from the MeshBuilder class instead
  21067. * @see http://doc.babylonjs.com/babylon101/height_map
  21068. * @param name defines the name of the mesh to create
  21069. * @param url sets the URL of the height map image resource
  21070. * @param width set the ground width size
  21071. * @param height set the ground height size
  21072. * @param subdivisions sets the number of subdivision per side
  21073. * @param minHeight is the minimum altitude on the ground
  21074. * @param maxHeight is the maximum altitude on the ground
  21075. * @param scene defines the hosting scene
  21076. * @param updatable defines if the mesh must be flagged as updatable
  21077. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21078. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21079. * @returns a new Mesh
  21080. */
  21081. 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;
  21082. /**
  21083. * Creates a tube mesh.
  21084. * The tube is a parametric shape.
  21085. * It has no predefined shape. Its final shape will depend on the input parameters.
  21086. * Please consider using the same method from the MeshBuilder class instead
  21087. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21088. * @param name defines the name of the mesh to create
  21089. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21090. * @param radius sets the tube radius size
  21091. * @param tessellation is the number of sides on the tubular surface
  21092. * @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
  21093. * @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
  21094. * @param scene defines the hosting scene
  21095. * @param updatable defines if the mesh must be flagged as updatable
  21096. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21097. * @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)
  21098. * @returns a new Mesh
  21099. */
  21100. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21101. (i: number, distance: number): number;
  21102. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21103. /**
  21104. * Creates a polyhedron mesh.
  21105. * Please consider using the same method from the MeshBuilder class instead.
  21106. * * 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
  21107. * * The parameter `size` (positive float, default 1) sets the polygon size
  21108. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21109. * * 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`
  21110. * * 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
  21111. * * 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)`)
  21112. * * 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
  21113. * * 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
  21114. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21115. * * If you create a double-sided mesh, you can choose what parts of 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
  21116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21117. * @param name defines the name of the mesh to create
  21118. * @param options defines the options used to create the mesh
  21119. * @param scene defines the hosting scene
  21120. * @returns a new Mesh
  21121. */
  21122. static CreatePolyhedron(name: string, options: {
  21123. type?: number;
  21124. size?: number;
  21125. sizeX?: number;
  21126. sizeY?: number;
  21127. sizeZ?: number;
  21128. custom?: any;
  21129. faceUV?: Vector4[];
  21130. faceColors?: Color4[];
  21131. updatable?: boolean;
  21132. sideOrientation?: number;
  21133. }, scene: Scene): Mesh;
  21134. /**
  21135. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21136. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21137. * * 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`)
  21138. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21139. * * 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
  21140. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21141. * * If you create a double-sided mesh, you can choose what parts of 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
  21142. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21143. * @param name defines the name of the mesh
  21144. * @param options defines the options used to create the mesh
  21145. * @param scene defines the hosting scene
  21146. * @returns a new Mesh
  21147. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21148. */
  21149. static CreateIcoSphere(name: string, options: {
  21150. radius?: number;
  21151. flat?: boolean;
  21152. subdivisions?: number;
  21153. sideOrientation?: number;
  21154. updatable?: boolean;
  21155. }, scene: Scene): Mesh;
  21156. /**
  21157. * Creates a decal mesh.
  21158. * Please consider using the same method from the MeshBuilder class instead.
  21159. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21160. * @param name defines the name of the mesh
  21161. * @param sourceMesh defines the mesh receiving the decal
  21162. * @param position sets the position of the decal in world coordinates
  21163. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21164. * @param size sets the decal scaling
  21165. * @param angle sets the angle to rotate the decal
  21166. * @returns a new Mesh
  21167. */
  21168. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21169. /**
  21170. * Prepare internal position array for software CPU skinning
  21171. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21172. */
  21173. setPositionsForCPUSkinning(): Float32Array;
  21174. /**
  21175. * Prepare internal normal array for software CPU skinning
  21176. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21177. */
  21178. setNormalsForCPUSkinning(): Float32Array;
  21179. /**
  21180. * Updates the vertex buffer by applying transformation from the bones
  21181. * @param skeleton defines the skeleton to apply to current mesh
  21182. * @returns the current mesh
  21183. */
  21184. applySkeleton(skeleton: Skeleton): Mesh;
  21185. /**
  21186. * 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
  21187. * @param meshes defines the list of meshes to scan
  21188. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21189. */
  21190. static MinMax(meshes: AbstractMesh[]): {
  21191. min: Vector3;
  21192. max: Vector3;
  21193. };
  21194. /**
  21195. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21196. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21197. * @returns a vector3
  21198. */
  21199. static Center(meshesOrMinMaxVector: {
  21200. min: Vector3;
  21201. max: Vector3;
  21202. } | AbstractMesh[]): Vector3;
  21203. /**
  21204. * Merge the array of meshes into a single mesh for performance reasons.
  21205. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21206. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21207. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21208. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21209. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21210. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21211. * @returns a new mesh
  21212. */
  21213. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21214. /** @hidden */
  21215. addInstance(instance: InstancedMesh): void;
  21216. /** @hidden */
  21217. removeInstance(instance: InstancedMesh): void;
  21218. }
  21219. }
  21220. declare module BABYLON {
  21221. /**
  21222. * Base class for the main features of a material in Babylon.js
  21223. */
  21224. export class Material implements IAnimatable {
  21225. /**
  21226. * Returns the triangle fill mode
  21227. */
  21228. static readonly TriangleFillMode: number;
  21229. /**
  21230. * Returns the wireframe mode
  21231. */
  21232. static readonly WireFrameFillMode: number;
  21233. /**
  21234. * Returns the point fill mode
  21235. */
  21236. static readonly PointFillMode: number;
  21237. /**
  21238. * Returns the point list draw mode
  21239. */
  21240. static readonly PointListDrawMode: number;
  21241. /**
  21242. * Returns the line list draw mode
  21243. */
  21244. static readonly LineListDrawMode: number;
  21245. /**
  21246. * Returns the line loop draw mode
  21247. */
  21248. static readonly LineLoopDrawMode: number;
  21249. /**
  21250. * Returns the line strip draw mode
  21251. */
  21252. static readonly LineStripDrawMode: number;
  21253. /**
  21254. * Returns the triangle strip draw mode
  21255. */
  21256. static readonly TriangleStripDrawMode: number;
  21257. /**
  21258. * Returns the triangle fan draw mode
  21259. */
  21260. static readonly TriangleFanDrawMode: number;
  21261. /**
  21262. * Stores the clock-wise side orientation
  21263. */
  21264. static readonly ClockWiseSideOrientation: number;
  21265. /**
  21266. * Stores the counter clock-wise side orientation
  21267. */
  21268. static readonly CounterClockWiseSideOrientation: number;
  21269. /**
  21270. * The dirty texture flag value
  21271. */
  21272. static readonly TextureDirtyFlag: number;
  21273. /**
  21274. * The dirty light flag value
  21275. */
  21276. static readonly LightDirtyFlag: number;
  21277. /**
  21278. * The dirty fresnel flag value
  21279. */
  21280. static readonly FresnelDirtyFlag: number;
  21281. /**
  21282. * The dirty attribute flag value
  21283. */
  21284. static readonly AttributesDirtyFlag: number;
  21285. /**
  21286. * The dirty misc flag value
  21287. */
  21288. static readonly MiscDirtyFlag: number;
  21289. /**
  21290. * The all dirty flag value
  21291. */
  21292. static readonly AllDirtyFlag: number;
  21293. /**
  21294. * The ID of the material
  21295. */
  21296. id: string;
  21297. /**
  21298. * Gets or sets the unique id of the material
  21299. */
  21300. uniqueId: number;
  21301. /**
  21302. * The name of the material
  21303. */
  21304. name: string;
  21305. /**
  21306. * Gets or sets user defined metadata
  21307. */
  21308. metadata: any;
  21309. /**
  21310. * For internal use only. Please do not use.
  21311. */
  21312. reservedDataStore: any;
  21313. /**
  21314. * Specifies if the ready state should be checked on each call
  21315. */
  21316. checkReadyOnEveryCall: boolean;
  21317. /**
  21318. * Specifies if the ready state should be checked once
  21319. */
  21320. checkReadyOnlyOnce: boolean;
  21321. /**
  21322. * The state of the material
  21323. */
  21324. state: string;
  21325. /**
  21326. * The alpha value of the material
  21327. */
  21328. protected _alpha: number;
  21329. /**
  21330. * List of inspectable custom properties (used by the Inspector)
  21331. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21332. */
  21333. inspectableCustomProperties: IInspectable[];
  21334. /**
  21335. * Sets the alpha value of the material
  21336. */
  21337. /**
  21338. * Gets the alpha value of the material
  21339. */
  21340. alpha: number;
  21341. /**
  21342. * Specifies if back face culling is enabled
  21343. */
  21344. protected _backFaceCulling: boolean;
  21345. /**
  21346. * Sets the back-face culling state
  21347. */
  21348. /**
  21349. * Gets the back-face culling state
  21350. */
  21351. backFaceCulling: boolean;
  21352. /**
  21353. * Stores the value for side orientation
  21354. */
  21355. sideOrientation: number;
  21356. /**
  21357. * Callback triggered when the material is compiled
  21358. */
  21359. onCompiled: (effect: Effect) => void;
  21360. /**
  21361. * Callback triggered when an error occurs
  21362. */
  21363. onError: (effect: Effect, errors: string) => void;
  21364. /**
  21365. * Callback triggered to get the render target textures
  21366. */
  21367. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  21368. /**
  21369. * Gets a boolean indicating that current material needs to register RTT
  21370. */
  21371. readonly hasRenderTargetTextures: boolean;
  21372. /**
  21373. * Specifies if the material should be serialized
  21374. */
  21375. doNotSerialize: boolean;
  21376. /**
  21377. * @hidden
  21378. */ storeEffectOnSubMeshes: boolean;
  21379. /**
  21380. * Stores the animations for the material
  21381. */
  21382. animations: Array<Animation>;
  21383. /**
  21384. * An event triggered when the material is disposed
  21385. */
  21386. onDisposeObservable: Observable<Material>;
  21387. /**
  21388. * An observer which watches for dispose events
  21389. */
  21390. private _onDisposeObserver;
  21391. private _onUnBindObservable;
  21392. /**
  21393. * Called during a dispose event
  21394. */
  21395. onDispose: () => void;
  21396. private _onBindObservable;
  21397. /**
  21398. * An event triggered when the material is bound
  21399. */
  21400. readonly onBindObservable: Observable<AbstractMesh>;
  21401. /**
  21402. * An observer which watches for bind events
  21403. */
  21404. private _onBindObserver;
  21405. /**
  21406. * Called during a bind event
  21407. */
  21408. onBind: (Mesh: AbstractMesh) => void;
  21409. /**
  21410. * An event triggered when the material is unbound
  21411. */
  21412. readonly onUnBindObservable: Observable<Material>;
  21413. /**
  21414. * Stores the value of the alpha mode
  21415. */
  21416. private _alphaMode;
  21417. /**
  21418. * Sets the value of the alpha mode.
  21419. *
  21420. * | Value | Type | Description |
  21421. * | --- | --- | --- |
  21422. * | 0 | ALPHA_DISABLE | |
  21423. * | 1 | ALPHA_ADD | |
  21424. * | 2 | ALPHA_COMBINE | |
  21425. * | 3 | ALPHA_SUBTRACT | |
  21426. * | 4 | ALPHA_MULTIPLY | |
  21427. * | 5 | ALPHA_MAXIMIZED | |
  21428. * | 6 | ALPHA_ONEONE | |
  21429. * | 7 | ALPHA_PREMULTIPLIED | |
  21430. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21431. * | 9 | ALPHA_INTERPOLATE | |
  21432. * | 10 | ALPHA_SCREENMODE | |
  21433. *
  21434. */
  21435. /**
  21436. * Gets the value of the alpha mode
  21437. */
  21438. alphaMode: number;
  21439. /**
  21440. * Stores the state of the need depth pre-pass value
  21441. */
  21442. private _needDepthPrePass;
  21443. /**
  21444. * Sets the need depth pre-pass value
  21445. */
  21446. /**
  21447. * Gets the depth pre-pass value
  21448. */
  21449. needDepthPrePass: boolean;
  21450. /**
  21451. * Specifies if depth writing should be disabled
  21452. */
  21453. disableDepthWrite: boolean;
  21454. /**
  21455. * Specifies if depth writing should be forced
  21456. */
  21457. forceDepthWrite: boolean;
  21458. /**
  21459. * Specifies if there should be a separate pass for culling
  21460. */
  21461. separateCullingPass: boolean;
  21462. /**
  21463. * Stores the state specifing if fog should be enabled
  21464. */
  21465. private _fogEnabled;
  21466. /**
  21467. * Sets the state for enabling fog
  21468. */
  21469. /**
  21470. * Gets the value of the fog enabled state
  21471. */
  21472. fogEnabled: boolean;
  21473. /**
  21474. * Stores the size of points
  21475. */
  21476. pointSize: number;
  21477. /**
  21478. * Stores the z offset value
  21479. */
  21480. zOffset: number;
  21481. /**
  21482. * Gets a value specifying if wireframe mode is enabled
  21483. */
  21484. /**
  21485. * Sets the state of wireframe mode
  21486. */
  21487. wireframe: boolean;
  21488. /**
  21489. * Gets the value specifying if point clouds are enabled
  21490. */
  21491. /**
  21492. * Sets the state of point cloud mode
  21493. */
  21494. pointsCloud: boolean;
  21495. /**
  21496. * Gets the material fill mode
  21497. */
  21498. /**
  21499. * Sets the material fill mode
  21500. */
  21501. fillMode: number;
  21502. /**
  21503. * @hidden
  21504. * Stores the effects for the material
  21505. */ effect: Nullable<Effect>;
  21506. /**
  21507. * @hidden
  21508. * Specifies if the material was previously ready
  21509. */ wasPreviouslyReady: boolean;
  21510. /**
  21511. * Specifies if uniform buffers should be used
  21512. */
  21513. private _useUBO;
  21514. /**
  21515. * Stores a reference to the scene
  21516. */
  21517. private _scene;
  21518. /**
  21519. * Stores the fill mode state
  21520. */
  21521. private _fillMode;
  21522. /**
  21523. * Specifies if the depth write state should be cached
  21524. */
  21525. private _cachedDepthWriteState;
  21526. /**
  21527. * Stores the uniform buffer
  21528. */
  21529. protected _uniformBuffer: UniformBuffer;
  21530. /** @hidden */ indexInSceneMaterialArray: number;
  21531. /** @hidden */
  21532. meshMap: Nullable<{
  21533. [id: string]: AbstractMesh | undefined;
  21534. }>;
  21535. /**
  21536. * Creates a material instance
  21537. * @param name defines the name of the material
  21538. * @param scene defines the scene to reference
  21539. * @param doNotAdd specifies if the material should be added to the scene
  21540. */
  21541. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21542. /**
  21543. * Returns a string representation of the current material
  21544. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21545. * @returns a string with material information
  21546. */
  21547. toString(fullDetails?: boolean): string;
  21548. /**
  21549. * Gets the class name of the material
  21550. * @returns a string with the class name of the material
  21551. */
  21552. getClassName(): string;
  21553. /**
  21554. * Specifies if updates for the material been locked
  21555. */
  21556. readonly isFrozen: boolean;
  21557. /**
  21558. * Locks updates for the material
  21559. */
  21560. freeze(): void;
  21561. /**
  21562. * Unlocks updates for the material
  21563. */
  21564. unfreeze(): void;
  21565. /**
  21566. * Specifies if the material is ready to be used
  21567. * @param mesh defines the mesh to check
  21568. * @param useInstances specifies if instances should be used
  21569. * @returns a boolean indicating if the material is ready to be used
  21570. */
  21571. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21572. /**
  21573. * Specifies that the submesh is ready to be used
  21574. * @param mesh defines the mesh to check
  21575. * @param subMesh defines which submesh to check
  21576. * @param useInstances specifies that instances should be used
  21577. * @returns a boolean indicating that the submesh is ready or not
  21578. */
  21579. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21580. /**
  21581. * Returns the material effect
  21582. * @returns the effect associated with the material
  21583. */
  21584. getEffect(): Nullable<Effect>;
  21585. /**
  21586. * Returns the current scene
  21587. * @returns a Scene
  21588. */
  21589. getScene(): Scene;
  21590. /**
  21591. * Specifies if the material will require alpha blending
  21592. * @returns a boolean specifying if alpha blending is needed
  21593. */
  21594. needAlphaBlending(): boolean;
  21595. /**
  21596. * Specifies if the mesh will require alpha blending
  21597. * @param mesh defines the mesh to check
  21598. * @returns a boolean specifying if alpha blending is needed for the mesh
  21599. */
  21600. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21601. /**
  21602. * Specifies if this material should be rendered in alpha test mode
  21603. * @returns a boolean specifying if an alpha test is needed.
  21604. */
  21605. needAlphaTesting(): boolean;
  21606. /**
  21607. * Gets the texture used for the alpha test
  21608. * @returns the texture to use for alpha testing
  21609. */
  21610. getAlphaTestTexture(): Nullable<BaseTexture>;
  21611. /**
  21612. * Marks the material to indicate that it needs to be re-calculated
  21613. */
  21614. markDirty(): void;
  21615. /** @hidden */ preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21616. /**
  21617. * Binds the material to the mesh
  21618. * @param world defines the world transformation matrix
  21619. * @param mesh defines the mesh to bind the material to
  21620. */
  21621. bind(world: Matrix, mesh?: Mesh): void;
  21622. /**
  21623. * Binds the submesh to the material
  21624. * @param world defines the world transformation matrix
  21625. * @param mesh defines the mesh containing the submesh
  21626. * @param subMesh defines the submesh to bind the material to
  21627. */
  21628. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21629. /**
  21630. * Binds the world matrix to the material
  21631. * @param world defines the world transformation matrix
  21632. */
  21633. bindOnlyWorldMatrix(world: Matrix): void;
  21634. /**
  21635. * Binds the scene's uniform buffer to the effect.
  21636. * @param effect defines the effect to bind to the scene uniform buffer
  21637. * @param sceneUbo defines the uniform buffer storing scene data
  21638. */
  21639. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21640. /**
  21641. * Binds the view matrix to the effect
  21642. * @param effect defines the effect to bind the view matrix to
  21643. */
  21644. bindView(effect: Effect): void;
  21645. /**
  21646. * Binds the view projection matrix to the effect
  21647. * @param effect defines the effect to bind the view projection matrix to
  21648. */
  21649. bindViewProjection(effect: Effect): void;
  21650. /**
  21651. * Specifies if material alpha testing should be turned on for the mesh
  21652. * @param mesh defines the mesh to check
  21653. */
  21654. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21655. /**
  21656. * Processes to execute after binding the material to a mesh
  21657. * @param mesh defines the rendered mesh
  21658. */
  21659. protected _afterBind(mesh?: Mesh): void;
  21660. /**
  21661. * Unbinds the material from the mesh
  21662. */
  21663. unbind(): void;
  21664. /**
  21665. * Gets the active textures from the material
  21666. * @returns an array of textures
  21667. */
  21668. getActiveTextures(): BaseTexture[];
  21669. /**
  21670. * Specifies if the material uses a texture
  21671. * @param texture defines the texture to check against the material
  21672. * @returns a boolean specifying if the material uses the texture
  21673. */
  21674. hasTexture(texture: BaseTexture): boolean;
  21675. /**
  21676. * Makes a duplicate of the material, and gives it a new name
  21677. * @param name defines the new name for the duplicated material
  21678. * @returns the cloned material
  21679. */
  21680. clone(name: string): Nullable<Material>;
  21681. /**
  21682. * Gets the meshes bound to the material
  21683. * @returns an array of meshes bound to the material
  21684. */
  21685. getBindedMeshes(): AbstractMesh[];
  21686. /**
  21687. * Force shader compilation
  21688. * @param mesh defines the mesh associated with this material
  21689. * @param onCompiled defines a function to execute once the material is compiled
  21690. * @param options defines the options to configure the compilation
  21691. */
  21692. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21693. clipPlane: boolean;
  21694. }>): void;
  21695. /**
  21696. * Force shader compilation
  21697. * @param mesh defines the mesh that will use this material
  21698. * @param options defines additional options for compiling the shaders
  21699. * @returns a promise that resolves when the compilation completes
  21700. */
  21701. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21702. clipPlane: boolean;
  21703. }>): Promise<void>;
  21704. private static readonly _ImageProcessingDirtyCallBack;
  21705. private static readonly _TextureDirtyCallBack;
  21706. private static readonly _FresnelDirtyCallBack;
  21707. private static readonly _MiscDirtyCallBack;
  21708. private static readonly _LightsDirtyCallBack;
  21709. private static readonly _AttributeDirtyCallBack;
  21710. private static _FresnelAndMiscDirtyCallBack;
  21711. private static _TextureAndMiscDirtyCallBack;
  21712. private static readonly _DirtyCallbackArray;
  21713. private static readonly _RunDirtyCallBacks;
  21714. /**
  21715. * Marks a define in the material to indicate that it needs to be re-computed
  21716. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21717. */
  21718. markAsDirty(flag: number): void;
  21719. /**
  21720. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21721. * @param func defines a function which checks material defines against the submeshes
  21722. */
  21723. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21724. /**
  21725. * Indicates that image processing needs to be re-calculated for all submeshes
  21726. */
  21727. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21728. /**
  21729. * Indicates that textures need to be re-calculated for all submeshes
  21730. */
  21731. protected _markAllSubMeshesAsTexturesDirty(): void;
  21732. /**
  21733. * Indicates that fresnel needs to be re-calculated for all submeshes
  21734. */
  21735. protected _markAllSubMeshesAsFresnelDirty(): void;
  21736. /**
  21737. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21738. */
  21739. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21740. /**
  21741. * Indicates that lights need to be re-calculated for all submeshes
  21742. */
  21743. protected _markAllSubMeshesAsLightsDirty(): void;
  21744. /**
  21745. * Indicates that attributes need to be re-calculated for all submeshes
  21746. */
  21747. protected _markAllSubMeshesAsAttributesDirty(): void;
  21748. /**
  21749. * Indicates that misc needs to be re-calculated for all submeshes
  21750. */
  21751. protected _markAllSubMeshesAsMiscDirty(): void;
  21752. /**
  21753. * Indicates that textures and misc need to be re-calculated for all submeshes
  21754. */
  21755. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21756. /**
  21757. * Disposes the material
  21758. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21759. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21760. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21761. */
  21762. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21763. /** @hidden */
  21764. private releaseVertexArrayObject;
  21765. /**
  21766. * Serializes this material
  21767. * @returns the serialized material object
  21768. */
  21769. serialize(): any;
  21770. /**
  21771. * Creates a material from parsed material data
  21772. * @param parsedMaterial defines parsed material data
  21773. * @param scene defines the hosting scene
  21774. * @param rootUrl defines the root URL to use to load textures
  21775. * @returns a new material
  21776. */
  21777. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21778. }
  21779. }
  21780. declare module BABYLON {
  21781. /**
  21782. * Base class for submeshes
  21783. */
  21784. export class BaseSubMesh {
  21785. /** @hidden */ materialDefines: Nullable<MaterialDefines>;
  21786. /** @hidden */ materialEffect: Nullable<Effect>;
  21787. /**
  21788. * Gets associated effect
  21789. */
  21790. readonly effect: Nullable<Effect>;
  21791. /**
  21792. * Sets associated effect (effect used to render this submesh)
  21793. * @param effect defines the effect to associate with
  21794. * @param defines defines the set of defines used to compile this effect
  21795. */
  21796. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21797. }
  21798. /**
  21799. * Defines a subdivision inside a mesh
  21800. */
  21801. export class SubMesh extends BaseSubMesh implements ICullable {
  21802. /** the material index to use */
  21803. materialIndex: number;
  21804. /** vertex index start */
  21805. verticesStart: number;
  21806. /** vertices count */
  21807. verticesCount: number;
  21808. /** index start */
  21809. indexStart: number;
  21810. /** indices count */
  21811. indexCount: number;
  21812. /** @hidden */ linesIndexCount: number;
  21813. private _mesh;
  21814. private _renderingMesh;
  21815. private _boundingInfo;
  21816. private _linesIndexBuffer;
  21817. /** @hidden */ lastColliderWorldVertices: Nullable<Vector3[]>;
  21818. /** @hidden */ trianglePlanes: Plane[];
  21819. /** @hidden */ lastColliderTransformMatrix: Matrix;
  21820. /** @hidden */ renderId: number;
  21821. /** @hidden */ alphaIndex: number;
  21822. /** @hidden */ distanceToCamera: number;
  21823. /** @hidden */ id: number;
  21824. private _currentMaterial;
  21825. /**
  21826. * Add a new submesh to a mesh
  21827. * @param materialIndex defines the material index to use
  21828. * @param verticesStart defines vertex index start
  21829. * @param verticesCount defines vertices count
  21830. * @param indexStart defines index start
  21831. * @param indexCount defines indices count
  21832. * @param mesh defines the parent mesh
  21833. * @param renderingMesh defines an optional rendering mesh
  21834. * @param createBoundingBox defines if bounding box should be created for this submesh
  21835. * @returns the new submesh
  21836. */
  21837. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21838. /**
  21839. * Creates a new submesh
  21840. * @param materialIndex defines the material index to use
  21841. * @param verticesStart defines vertex index start
  21842. * @param verticesCount defines vertices count
  21843. * @param indexStart defines index start
  21844. * @param indexCount defines indices count
  21845. * @param mesh defines the parent mesh
  21846. * @param renderingMesh defines an optional rendering mesh
  21847. * @param createBoundingBox defines if bounding box should be created for this submesh
  21848. */
  21849. constructor(
  21850. /** the material index to use */
  21851. materialIndex: number,
  21852. /** vertex index start */
  21853. verticesStart: number,
  21854. /** vertices count */
  21855. verticesCount: number,
  21856. /** index start */
  21857. indexStart: number,
  21858. /** indices count */
  21859. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21860. /**
  21861. * Returns true if this submesh covers the entire parent mesh
  21862. * @ignorenaming
  21863. */
  21864. readonly IsGlobal: boolean;
  21865. /**
  21866. * Returns the submesh BoudingInfo object
  21867. * @returns current bounding info (or mesh's one if the submesh is global)
  21868. */
  21869. getBoundingInfo(): BoundingInfo;
  21870. /**
  21871. * Sets the submesh BoundingInfo
  21872. * @param boundingInfo defines the new bounding info to use
  21873. * @returns the SubMesh
  21874. */
  21875. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21876. /**
  21877. * Returns the mesh of the current submesh
  21878. * @return the parent mesh
  21879. */
  21880. getMesh(): AbstractMesh;
  21881. /**
  21882. * Returns the rendering mesh of the submesh
  21883. * @returns the rendering mesh (could be different from parent mesh)
  21884. */
  21885. getRenderingMesh(): Mesh;
  21886. /**
  21887. * Returns the submesh material
  21888. * @returns null or the current material
  21889. */
  21890. getMaterial(): Nullable<Material>;
  21891. /**
  21892. * Sets a new updated BoundingInfo object to the submesh
  21893. * @returns the SubMesh
  21894. */
  21895. refreshBoundingInfo(): SubMesh;
  21896. /** @hidden */ checkCollision(collider: Collider): boolean;
  21897. /**
  21898. * Updates the submesh BoundingInfo
  21899. * @param world defines the world matrix to use to update the bounding info
  21900. * @returns the submesh
  21901. */
  21902. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21903. /**
  21904. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21905. * @param frustumPlanes defines the frustum planes
  21906. * @returns true if the submesh is intersecting with the frustum
  21907. */
  21908. isInFrustum(frustumPlanes: Plane[]): boolean;
  21909. /**
  21910. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21911. * @param frustumPlanes defines the frustum planes
  21912. * @returns true if the submesh is inside the frustum
  21913. */
  21914. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21915. /**
  21916. * Renders the submesh
  21917. * @param enableAlphaMode defines if alpha needs to be used
  21918. * @returns the submesh
  21919. */
  21920. render(enableAlphaMode: boolean): SubMesh;
  21921. /**
  21922. * @hidden
  21923. */ getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  21924. /**
  21925. * Checks if the submesh intersects with a ray
  21926. * @param ray defines the ray to test
  21927. * @returns true is the passed ray intersects the submesh bounding box
  21928. */
  21929. canIntersects(ray: Ray): boolean;
  21930. /**
  21931. * Intersects current submesh with a ray
  21932. * @param ray defines the ray to test
  21933. * @param positions defines mesh's positions array
  21934. * @param indices defines mesh's indices array
  21935. * @param fastCheck defines if only bounding info should be used
  21936. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21937. * @returns intersection info or null if no intersection
  21938. */
  21939. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21940. /** @hidden */
  21941. private _intersectLines;
  21942. /** @hidden */
  21943. private _intersectTriangles;
  21944. /** @hidden */ rebuild(): void;
  21945. /**
  21946. * Creates a new submesh from the passed mesh
  21947. * @param newMesh defines the new hosting mesh
  21948. * @param newRenderingMesh defines an optional rendering mesh
  21949. * @returns the new submesh
  21950. */
  21951. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21952. /**
  21953. * Release associated resources
  21954. */
  21955. dispose(): void;
  21956. /**
  21957. * Gets the class name
  21958. * @returns the string "SubMesh".
  21959. */
  21960. getClassName(): string;
  21961. /**
  21962. * Creates a new submesh from indices data
  21963. * @param materialIndex the index of the main mesh material
  21964. * @param startIndex the index where to start the copy in the mesh indices array
  21965. * @param indexCount the number of indices to copy then from the startIndex
  21966. * @param mesh the main mesh to create the submesh from
  21967. * @param renderingMesh the optional rendering mesh
  21968. * @returns a new submesh
  21969. */
  21970. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21971. }
  21972. }
  21973. declare module BABYLON {
  21974. /**
  21975. * Class used to store geometry data (vertex buffers + index buffer)
  21976. */
  21977. export class Geometry implements IGetSetVerticesData {
  21978. /**
  21979. * Gets or sets the ID of the geometry
  21980. */
  21981. id: string;
  21982. /**
  21983. * Gets or sets the unique ID of the geometry
  21984. */
  21985. uniqueId: number;
  21986. /**
  21987. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21988. */
  21989. delayLoadState: number;
  21990. /**
  21991. * Gets the file containing the data to load when running in delay load state
  21992. */
  21993. delayLoadingFile: Nullable<string>;
  21994. /**
  21995. * Callback called when the geometry is updated
  21996. */
  21997. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21998. private _scene;
  21999. private _engine;
  22000. private _meshes;
  22001. private _totalVertices;
  22002. /** @hidden */ indices: IndicesArray;
  22003. /** @hidden */ vertexBuffers: {
  22004. [key: string]: VertexBuffer;
  22005. };
  22006. private _isDisposed;
  22007. private _extend;
  22008. private _boundingBias;
  22009. /** @hidden */ delayInfo: Array<string>;
  22010. private _indexBuffer;
  22011. private _indexBufferIsUpdatable;
  22012. /** @hidden */ boundingInfo: Nullable<BoundingInfo>;
  22013. /** @hidden */ delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22014. /** @hidden */ softwareSkinningFrameId: number;
  22015. private _vertexArrayObjects;
  22016. private _updatable;
  22017. /** @hidden */ positions: Nullable<Vector3[]>;
  22018. /**
  22019. * 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
  22020. */
  22021. /**
  22022. * 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
  22023. */
  22024. boundingBias: Vector2;
  22025. /**
  22026. * Static function used to attach a new empty geometry to a mesh
  22027. * @param mesh defines the mesh to attach the geometry to
  22028. * @returns the new Geometry
  22029. */
  22030. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22031. /**
  22032. * Creates a new geometry
  22033. * @param id defines the unique ID
  22034. * @param scene defines the hosting scene
  22035. * @param vertexData defines the VertexData used to get geometry data
  22036. * @param updatable defines if geometry must be updatable (false by default)
  22037. * @param mesh defines the mesh that will be associated with the geometry
  22038. */
  22039. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22040. /**
  22041. * Gets the current extend of the geometry
  22042. */
  22043. readonly extend: {
  22044. minimum: Vector3;
  22045. maximum: Vector3;
  22046. };
  22047. /**
  22048. * Gets the hosting scene
  22049. * @returns the hosting Scene
  22050. */
  22051. getScene(): Scene;
  22052. /**
  22053. * Gets the hosting engine
  22054. * @returns the hosting Engine
  22055. */
  22056. getEngine(): Engine;
  22057. /**
  22058. * Defines if the geometry is ready to use
  22059. * @returns true if the geometry is ready to be used
  22060. */
  22061. isReady(): boolean;
  22062. /**
  22063. * Gets a value indicating that the geometry should not be serialized
  22064. */
  22065. readonly doNotSerialize: boolean;
  22066. /** @hidden */ rebuild(): void;
  22067. /**
  22068. * Affects all geometry data in one call
  22069. * @param vertexData defines the geometry data
  22070. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22071. */
  22072. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22073. /**
  22074. * Set specific vertex data
  22075. * @param kind defines the data kind (Position, normal, etc...)
  22076. * @param data defines the vertex data to use
  22077. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22078. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22079. */
  22080. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22081. /**
  22082. * Removes a specific vertex data
  22083. * @param kind defines the data kind (Position, normal, etc...)
  22084. */
  22085. removeVerticesData(kind: string): void;
  22086. /**
  22087. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22088. * @param buffer defines the vertex buffer to use
  22089. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22090. */
  22091. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22092. /**
  22093. * Update a specific vertex buffer
  22094. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22095. * It will do nothing if the buffer is not updatable
  22096. * @param kind defines the data kind (Position, normal, etc...)
  22097. * @param data defines the data to use
  22098. * @param offset defines the offset in the target buffer where to store the data
  22099. * @param useBytes set to true if the offset is in bytes
  22100. */
  22101. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22102. /**
  22103. * Update a specific vertex buffer
  22104. * This function will create a new buffer if the current one is not updatable
  22105. * @param kind defines the data kind (Position, normal, etc...)
  22106. * @param data defines the data to use
  22107. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22108. */
  22109. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22110. private _updateBoundingInfo;
  22111. /** @hidden */ bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22112. /**
  22113. * Gets total number of vertices
  22114. * @returns the total number of vertices
  22115. */
  22116. getTotalVertices(): number;
  22117. /**
  22118. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22119. * @param kind defines the data kind (Position, normal, etc...)
  22120. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22121. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22122. * @returns a float array containing vertex data
  22123. */
  22124. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22125. /**
  22126. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22127. * @param kind defines the data kind (Position, normal, etc...)
  22128. * @returns true if the vertex buffer with the specified kind is updatable
  22129. */
  22130. isVertexBufferUpdatable(kind: string): boolean;
  22131. /**
  22132. * Gets a specific vertex buffer
  22133. * @param kind defines the data kind (Position, normal, etc...)
  22134. * @returns a VertexBuffer
  22135. */
  22136. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22137. /**
  22138. * Returns all vertex buffers
  22139. * @return an object holding all vertex buffers indexed by kind
  22140. */
  22141. getVertexBuffers(): Nullable<{
  22142. [key: string]: VertexBuffer;
  22143. }>;
  22144. /**
  22145. * Gets a boolean indicating if specific vertex buffer is present
  22146. * @param kind defines the data kind (Position, normal, etc...)
  22147. * @returns true if data is present
  22148. */
  22149. isVerticesDataPresent(kind: string): boolean;
  22150. /**
  22151. * Gets a list of all attached data kinds (Position, normal, etc...)
  22152. * @returns a list of string containing all kinds
  22153. */
  22154. getVerticesDataKinds(): string[];
  22155. /**
  22156. * Update index buffer
  22157. * @param indices defines the indices to store in the index buffer
  22158. * @param offset defines the offset in the target buffer where to store the data
  22159. * @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)
  22160. */
  22161. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22162. /**
  22163. * Creates a new index buffer
  22164. * @param indices defines the indices to store in the index buffer
  22165. * @param totalVertices defines the total number of vertices (could be null)
  22166. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22167. */
  22168. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22169. /**
  22170. * Return the total number of indices
  22171. * @returns the total number of indices
  22172. */
  22173. getTotalIndices(): number;
  22174. /**
  22175. * Gets the index buffer array
  22176. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22177. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22178. * @returns the index buffer array
  22179. */
  22180. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22181. /**
  22182. * Gets the index buffer
  22183. * @return the index buffer
  22184. */
  22185. getIndexBuffer(): Nullable<WebGLBuffer>;
  22186. /** @hidden */ releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22187. /**
  22188. * Release the associated resources for a specific mesh
  22189. * @param mesh defines the source mesh
  22190. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22191. */
  22192. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22193. /**
  22194. * Apply current geometry to a given mesh
  22195. * @param mesh defines the mesh to apply geometry to
  22196. */
  22197. applyToMesh(mesh: Mesh): void;
  22198. private _updateExtend;
  22199. private _applyToMesh;
  22200. private notifyUpdate;
  22201. /**
  22202. * Load the geometry if it was flagged as delay loaded
  22203. * @param scene defines the hosting scene
  22204. * @param onLoaded defines a callback called when the geometry is loaded
  22205. */
  22206. load(scene: Scene, onLoaded?: () => void): void;
  22207. private _queueLoad;
  22208. /**
  22209. * Invert the geometry to move from a right handed system to a left handed one.
  22210. */
  22211. toLeftHanded(): void;
  22212. /** @hidden */ resetPointsArrayCache(): void;
  22213. /** @hidden */ generatePointsArray(): boolean;
  22214. /**
  22215. * Gets a value indicating if the geometry is disposed
  22216. * @returns true if the geometry was disposed
  22217. */
  22218. isDisposed(): boolean;
  22219. private _disposeVertexArrayObjects;
  22220. /**
  22221. * Free all associated resources
  22222. */
  22223. dispose(): void;
  22224. /**
  22225. * Clone the current geometry into a new geometry
  22226. * @param id defines the unique ID of the new geometry
  22227. * @returns a new geometry object
  22228. */
  22229. copy(id: string): Geometry;
  22230. /**
  22231. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22232. * @return a JSON representation of the current geometry data (without the vertices data)
  22233. */
  22234. serialize(): any;
  22235. private toNumberArray;
  22236. /**
  22237. * Serialize all vertices data into a JSON oject
  22238. * @returns a JSON representation of the current geometry data
  22239. */
  22240. serializeVerticeData(): any;
  22241. /**
  22242. * Extracts a clone of a mesh geometry
  22243. * @param mesh defines the source mesh
  22244. * @param id defines the unique ID of the new geometry object
  22245. * @returns the new geometry object
  22246. */
  22247. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22248. /**
  22249. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22250. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22251. * Be aware Math.random() could cause collisions, but:
  22252. * "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"
  22253. * @returns a string containing a new GUID
  22254. */
  22255. static RandomId(): string;
  22256. /** @hidden */ private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22257. private static _CleanMatricesWeights;
  22258. /**
  22259. * Create a new geometry from persisted data (Using .babylon file format)
  22260. * @param parsedVertexData defines the persisted data
  22261. * @param scene defines the hosting scene
  22262. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22263. * @returns the new geometry object
  22264. */
  22265. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22266. }
  22267. }
  22268. declare module BABYLON {
  22269. /**
  22270. * Define an interface for all classes that will get and set the data on vertices
  22271. */
  22272. export interface IGetSetVerticesData {
  22273. /**
  22274. * Gets a boolean indicating if specific vertex data is present
  22275. * @param kind defines the vertex data kind to use
  22276. * @returns true is data kind is present
  22277. */
  22278. isVerticesDataPresent(kind: string): boolean;
  22279. /**
  22280. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22281. * @param kind defines the data kind (Position, normal, etc...)
  22282. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22283. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22284. * @returns a float array containing vertex data
  22285. */
  22286. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22287. /**
  22288. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22289. * @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.
  22290. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22291. * @returns the indices array or an empty array if the mesh has no geometry
  22292. */
  22293. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22294. /**
  22295. * Set specific vertex data
  22296. * @param kind defines the data kind (Position, normal, etc...)
  22297. * @param data defines the vertex data to use
  22298. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22299. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22300. */
  22301. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22302. /**
  22303. * Update a specific associated vertex buffer
  22304. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22305. * - VertexBuffer.PositionKind
  22306. * - VertexBuffer.UVKind
  22307. * - VertexBuffer.UV2Kind
  22308. * - VertexBuffer.UV3Kind
  22309. * - VertexBuffer.UV4Kind
  22310. * - VertexBuffer.UV5Kind
  22311. * - VertexBuffer.UV6Kind
  22312. * - VertexBuffer.ColorKind
  22313. * - VertexBuffer.MatricesIndicesKind
  22314. * - VertexBuffer.MatricesIndicesExtraKind
  22315. * - VertexBuffer.MatricesWeightsKind
  22316. * - VertexBuffer.MatricesWeightsExtraKind
  22317. * @param data defines the data source
  22318. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22319. * @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)
  22320. */
  22321. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22322. /**
  22323. * Creates a new index buffer
  22324. * @param indices defines the indices to store in the index buffer
  22325. * @param totalVertices defines the total number of vertices (could be null)
  22326. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22327. */
  22328. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22329. }
  22330. /**
  22331. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22332. */
  22333. export class VertexData {
  22334. /**
  22335. * Mesh side orientation : usually the external or front surface
  22336. */
  22337. static readonly FRONTSIDE: number;
  22338. /**
  22339. * Mesh side orientation : usually the internal or back surface
  22340. */
  22341. static readonly BACKSIDE: number;
  22342. /**
  22343. * Mesh side orientation : both internal and external or front and back surfaces
  22344. */
  22345. static readonly DOUBLESIDE: number;
  22346. /**
  22347. * Mesh side orientation : by default, `FRONTSIDE`
  22348. */
  22349. static readonly DEFAULTSIDE: number;
  22350. /**
  22351. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22352. */
  22353. positions: Nullable<FloatArray>;
  22354. /**
  22355. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22356. */
  22357. normals: Nullable<FloatArray>;
  22358. /**
  22359. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22360. */
  22361. tangents: Nullable<FloatArray>;
  22362. /**
  22363. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22364. */
  22365. uvs: Nullable<FloatArray>;
  22366. /**
  22367. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22368. */
  22369. uvs2: Nullable<FloatArray>;
  22370. /**
  22371. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22372. */
  22373. uvs3: Nullable<FloatArray>;
  22374. /**
  22375. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22376. */
  22377. uvs4: Nullable<FloatArray>;
  22378. /**
  22379. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22380. */
  22381. uvs5: Nullable<FloatArray>;
  22382. /**
  22383. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22384. */
  22385. uvs6: Nullable<FloatArray>;
  22386. /**
  22387. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22388. */
  22389. colors: Nullable<FloatArray>;
  22390. /**
  22391. * 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).
  22392. */
  22393. matricesIndices: Nullable<FloatArray>;
  22394. /**
  22395. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22396. */
  22397. matricesWeights: Nullable<FloatArray>;
  22398. /**
  22399. * An array extending the number of possible indices
  22400. */
  22401. matricesIndicesExtra: Nullable<FloatArray>;
  22402. /**
  22403. * An array extending the number of possible weights when the number of indices is extended
  22404. */
  22405. matricesWeightsExtra: Nullable<FloatArray>;
  22406. /**
  22407. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22408. */
  22409. indices: Nullable<IndicesArray>;
  22410. /**
  22411. * Uses the passed data array to set the set the values for the specified kind of data
  22412. * @param data a linear array of floating numbers
  22413. * @param kind the type of data that is being set, eg positions, colors etc
  22414. */
  22415. set(data: FloatArray, kind: string): void;
  22416. /**
  22417. * Associates the vertexData to the passed Mesh.
  22418. * Sets it as updatable or not (default `false`)
  22419. * @param mesh the mesh the vertexData is applied to
  22420. * @param updatable when used and having the value true allows new data to update the vertexData
  22421. * @returns the VertexData
  22422. */
  22423. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22424. /**
  22425. * Associates the vertexData to the passed Geometry.
  22426. * Sets it as updatable or not (default `false`)
  22427. * @param geometry the geometry the vertexData is applied to
  22428. * @param updatable when used and having the value true allows new data to update the vertexData
  22429. * @returns VertexData
  22430. */
  22431. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22432. /**
  22433. * Updates the associated mesh
  22434. * @param mesh the mesh to be updated
  22435. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22436. * @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
  22437. * @returns VertexData
  22438. */
  22439. updateMesh(mesh: Mesh): VertexData;
  22440. /**
  22441. * Updates the associated geometry
  22442. * @param geometry the geometry to be updated
  22443. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22444. * @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
  22445. * @returns VertexData.
  22446. */
  22447. updateGeometry(geometry: Geometry): VertexData;
  22448. private _applyTo;
  22449. private _update;
  22450. /**
  22451. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22452. * @param matrix the transforming matrix
  22453. * @returns the VertexData
  22454. */
  22455. transform(matrix: Matrix): VertexData;
  22456. /**
  22457. * Merges the passed VertexData into the current one
  22458. * @param other the VertexData to be merged into the current one
  22459. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22460. * @returns the modified VertexData
  22461. */
  22462. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22463. private _mergeElement;
  22464. private _validate;
  22465. /**
  22466. * Serializes the VertexData
  22467. * @returns a serialized object
  22468. */
  22469. serialize(): any;
  22470. /**
  22471. * Extracts the vertexData from a mesh
  22472. * @param mesh the mesh from which to extract the VertexData
  22473. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22474. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22475. * @returns the object VertexData associated to the passed mesh
  22476. */
  22477. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22478. /**
  22479. * Extracts the vertexData from the geometry
  22480. * @param geometry the geometry from which to extract the VertexData
  22481. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22482. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22483. * @returns the object VertexData associated to the passed mesh
  22484. */
  22485. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22486. private static _ExtractFrom;
  22487. /**
  22488. * Creates the VertexData for a Ribbon
  22489. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22490. * * pathArray array of paths, each of which an array of successive Vector3
  22491. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22492. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22493. * * 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
  22494. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22495. * * 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)
  22496. * * 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)
  22497. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22498. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22499. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22500. * @returns the VertexData of the ribbon
  22501. */
  22502. static CreateRibbon(options: {
  22503. pathArray: Vector3[][];
  22504. closeArray?: boolean;
  22505. closePath?: boolean;
  22506. offset?: number;
  22507. sideOrientation?: number;
  22508. frontUVs?: Vector4;
  22509. backUVs?: Vector4;
  22510. invertUV?: boolean;
  22511. uvs?: Vector2[];
  22512. colors?: Color4[];
  22513. }): VertexData;
  22514. /**
  22515. * Creates the VertexData for a box
  22516. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22517. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22518. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22519. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22520. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22521. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22522. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22523. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22524. * * 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)
  22525. * * 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)
  22526. * @returns the VertexData of the box
  22527. */
  22528. static CreateBox(options: {
  22529. size?: number;
  22530. width?: number;
  22531. height?: number;
  22532. depth?: number;
  22533. faceUV?: Vector4[];
  22534. faceColors?: Color4[];
  22535. sideOrientation?: number;
  22536. frontUVs?: Vector4;
  22537. backUVs?: Vector4;
  22538. }): VertexData;
  22539. /**
  22540. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22541. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22542. * * segments sets the number of horizontal strips optional, default 32
  22543. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22544. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22545. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22546. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22547. * * 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
  22548. * * 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
  22549. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22550. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22551. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22552. * @returns the VertexData of the ellipsoid
  22553. */
  22554. static CreateSphere(options: {
  22555. segments?: number;
  22556. diameter?: number;
  22557. diameterX?: number;
  22558. diameterY?: number;
  22559. diameterZ?: number;
  22560. arc?: number;
  22561. slice?: number;
  22562. sideOrientation?: number;
  22563. frontUVs?: Vector4;
  22564. backUVs?: Vector4;
  22565. }): VertexData;
  22566. /**
  22567. * Creates the VertexData for a cylinder, cone or prism
  22568. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22569. * * height sets the height (y direction) of the cylinder, optional, default 2
  22570. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22571. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22572. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22573. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22574. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22575. * * 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
  22576. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22577. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22578. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22579. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22580. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22581. * * 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)
  22582. * * 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)
  22583. * @returns the VertexData of the cylinder, cone or prism
  22584. */
  22585. static CreateCylinder(options: {
  22586. height?: number;
  22587. diameterTop?: number;
  22588. diameterBottom?: number;
  22589. diameter?: number;
  22590. tessellation?: number;
  22591. subdivisions?: number;
  22592. arc?: number;
  22593. faceColors?: Color4[];
  22594. faceUV?: Vector4[];
  22595. hasRings?: boolean;
  22596. enclose?: boolean;
  22597. sideOrientation?: number;
  22598. frontUVs?: Vector4;
  22599. backUVs?: Vector4;
  22600. }): VertexData;
  22601. /**
  22602. * Creates the VertexData for a torus
  22603. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22604. * * diameter the diameter of the torus, optional default 1
  22605. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22606. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22607. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22608. * * 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)
  22609. * * 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)
  22610. * @returns the VertexData of the torus
  22611. */
  22612. static CreateTorus(options: {
  22613. diameter?: number;
  22614. thickness?: number;
  22615. tessellation?: number;
  22616. sideOrientation?: number;
  22617. frontUVs?: Vector4;
  22618. backUVs?: Vector4;
  22619. }): VertexData;
  22620. /**
  22621. * Creates the VertexData of the LineSystem
  22622. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22623. * - lines an array of lines, each line being an array of successive Vector3
  22624. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22625. * @returns the VertexData of the LineSystem
  22626. */
  22627. static CreateLineSystem(options: {
  22628. lines: Vector3[][];
  22629. colors?: Nullable<Color4[][]>;
  22630. }): VertexData;
  22631. /**
  22632. * Create the VertexData for a DashedLines
  22633. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22634. * - points an array successive Vector3
  22635. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22636. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22637. * - dashNb the intended total number of dashes, optional, default 200
  22638. * @returns the VertexData for the DashedLines
  22639. */
  22640. static CreateDashedLines(options: {
  22641. points: Vector3[];
  22642. dashSize?: number;
  22643. gapSize?: number;
  22644. dashNb?: number;
  22645. }): VertexData;
  22646. /**
  22647. * Creates the VertexData for a Ground
  22648. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22649. * - width the width (x direction) of the ground, optional, default 1
  22650. * - height the height (z direction) of the ground, optional, default 1
  22651. * - subdivisions the number of subdivisions per side, optional, default 1
  22652. * @returns the VertexData of the Ground
  22653. */
  22654. static CreateGround(options: {
  22655. width?: number;
  22656. height?: number;
  22657. subdivisions?: number;
  22658. subdivisionsX?: number;
  22659. subdivisionsY?: number;
  22660. }): VertexData;
  22661. /**
  22662. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22663. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22664. * * xmin the ground minimum X coordinate, optional, default -1
  22665. * * zmin the ground minimum Z coordinate, optional, default -1
  22666. * * xmax the ground maximum X coordinate, optional, default 1
  22667. * * zmax the ground maximum Z coordinate, optional, default 1
  22668. * * 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}
  22669. * * 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}
  22670. * @returns the VertexData of the TiledGround
  22671. */
  22672. static CreateTiledGround(options: {
  22673. xmin: number;
  22674. zmin: number;
  22675. xmax: number;
  22676. zmax: number;
  22677. subdivisions?: {
  22678. w: number;
  22679. h: number;
  22680. };
  22681. precision?: {
  22682. w: number;
  22683. h: number;
  22684. };
  22685. }): VertexData;
  22686. /**
  22687. * Creates the VertexData of the Ground designed from a heightmap
  22688. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22689. * * width the width (x direction) of the ground
  22690. * * height the height (z direction) of the ground
  22691. * * subdivisions the number of subdivisions per side
  22692. * * minHeight the minimum altitude on the ground, optional, default 0
  22693. * * maxHeight the maximum altitude on the ground, optional default 1
  22694. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22695. * * buffer the array holding the image color data
  22696. * * bufferWidth the width of image
  22697. * * bufferHeight the height of image
  22698. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22699. * @returns the VertexData of the Ground designed from a heightmap
  22700. */
  22701. static CreateGroundFromHeightMap(options: {
  22702. width: number;
  22703. height: number;
  22704. subdivisions: number;
  22705. minHeight: number;
  22706. maxHeight: number;
  22707. colorFilter: Color3;
  22708. buffer: Uint8Array;
  22709. bufferWidth: number;
  22710. bufferHeight: number;
  22711. alphaFilter: number;
  22712. }): VertexData;
  22713. /**
  22714. * Creates the VertexData for a Plane
  22715. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22716. * * size sets the width and height of the plane to the value of size, optional default 1
  22717. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22718. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22719. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22720. * * 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)
  22721. * * 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)
  22722. * @returns the VertexData of the box
  22723. */
  22724. static CreatePlane(options: {
  22725. size?: number;
  22726. width?: number;
  22727. height?: number;
  22728. sideOrientation?: number;
  22729. frontUVs?: Vector4;
  22730. backUVs?: Vector4;
  22731. }): VertexData;
  22732. /**
  22733. * Creates the VertexData of the Disc or regular Polygon
  22734. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22735. * * radius the radius of the disc, optional default 0.5
  22736. * * tessellation the number of polygon sides, optional, default 64
  22737. * * 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
  22738. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22739. * * 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)
  22740. * * 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)
  22741. * @returns the VertexData of the box
  22742. */
  22743. static CreateDisc(options: {
  22744. radius?: number;
  22745. tessellation?: number;
  22746. arc?: number;
  22747. sideOrientation?: number;
  22748. frontUVs?: Vector4;
  22749. backUVs?: Vector4;
  22750. }): VertexData;
  22751. /**
  22752. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22753. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22754. * @param polygon a mesh built from polygonTriangulation.build()
  22755. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22756. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22757. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22758. * @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)
  22759. * @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)
  22760. * @returns the VertexData of the Polygon
  22761. */
  22762. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22763. /**
  22764. * Creates the VertexData of the IcoSphere
  22765. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22766. * * radius the radius of the IcoSphere, optional default 1
  22767. * * radiusX allows stretching in the x direction, optional, default radius
  22768. * * radiusY allows stretching in the y direction, optional, default radius
  22769. * * radiusZ allows stretching in the z direction, optional, default radius
  22770. * * flat when true creates a flat shaded mesh, optional, default true
  22771. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22772. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22773. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22774. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22775. * @returns the VertexData of the IcoSphere
  22776. */
  22777. static CreateIcoSphere(options: {
  22778. radius?: number;
  22779. radiusX?: number;
  22780. radiusY?: number;
  22781. radiusZ?: number;
  22782. flat?: boolean;
  22783. subdivisions?: number;
  22784. sideOrientation?: number;
  22785. frontUVs?: Vector4;
  22786. backUVs?: Vector4;
  22787. }): VertexData;
  22788. /**
  22789. * Creates the VertexData for a Polyhedron
  22790. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22791. * * type provided types are:
  22792. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22793. * * 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)
  22794. * * size the size of the IcoSphere, optional default 1
  22795. * * sizeX allows stretching in the x direction, optional, default size
  22796. * * sizeY allows stretching in the y direction, optional, default size
  22797. * * sizeZ allows stretching in the z direction, optional, default size
  22798. * * 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
  22799. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22800. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22801. * * flat when true creates a flat shaded mesh, optional, default true
  22802. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22803. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22804. * * 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)
  22805. * * 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)
  22806. * @returns the VertexData of the Polyhedron
  22807. */
  22808. static CreatePolyhedron(options: {
  22809. type?: number;
  22810. size?: number;
  22811. sizeX?: number;
  22812. sizeY?: number;
  22813. sizeZ?: number;
  22814. custom?: any;
  22815. faceUV?: Vector4[];
  22816. faceColors?: Color4[];
  22817. flat?: boolean;
  22818. sideOrientation?: number;
  22819. frontUVs?: Vector4;
  22820. backUVs?: Vector4;
  22821. }): VertexData;
  22822. /**
  22823. * Creates the VertexData for a TorusKnot
  22824. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22825. * * radius the radius of the torus knot, optional, default 2
  22826. * * tube the thickness of the tube, optional, default 0.5
  22827. * * radialSegments the number of sides on each tube segments, optional, default 32
  22828. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22829. * * p the number of windings around the z axis, optional, default 2
  22830. * * q the number of windings around the x axis, optional, default 3
  22831. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22832. * * 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)
  22833. * * 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)
  22834. * @returns the VertexData of the Torus Knot
  22835. */
  22836. static CreateTorusKnot(options: {
  22837. radius?: number;
  22838. tube?: number;
  22839. radialSegments?: number;
  22840. tubularSegments?: number;
  22841. p?: number;
  22842. q?: number;
  22843. sideOrientation?: number;
  22844. frontUVs?: Vector4;
  22845. backUVs?: Vector4;
  22846. }): VertexData;
  22847. /**
  22848. * Compute normals for given positions and indices
  22849. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22850. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22851. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22852. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22853. * * facetNormals : optional array of facet normals (vector3)
  22854. * * facetPositions : optional array of facet positions (vector3)
  22855. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22856. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22857. * * bInfo : optional bounding info, required for facetPartitioning computation
  22858. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22859. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22860. * * useRightHandedSystem: optional boolean to for right handed system computation
  22861. * * depthSort : optional boolean to enable the facet depth sort computation
  22862. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22863. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22864. */
  22865. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22866. facetNormals?: any;
  22867. facetPositions?: any;
  22868. facetPartitioning?: any;
  22869. ratio?: number;
  22870. bInfo?: any;
  22871. bbSize?: Vector3;
  22872. subDiv?: any;
  22873. useRightHandedSystem?: boolean;
  22874. depthSort?: boolean;
  22875. distanceTo?: Vector3;
  22876. depthSortedFacets?: any;
  22877. }): void;
  22878. /** @hidden */ private static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22879. /**
  22880. * Applies VertexData created from the imported parameters to the geometry
  22881. * @param parsedVertexData the parsed data from an imported file
  22882. * @param geometry the geometry to apply the VertexData to
  22883. */
  22884. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22885. }
  22886. }
  22887. declare module BABYLON {
  22888. /**
  22889. * Class containing static functions to help procedurally build meshes
  22890. */
  22891. export class DiscBuilder {
  22892. /**
  22893. * Creates a plane polygonal mesh. By default, this is a disc
  22894. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  22895. * * 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
  22896. * * 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
  22897. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22898. * * If you create a double-sided mesh, you can choose what parts of 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
  22899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22900. * @param name defines the name of the mesh
  22901. * @param options defines the options used to create the mesh
  22902. * @param scene defines the hosting scene
  22903. * @returns the plane polygonal mesh
  22904. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  22905. */
  22906. static CreateDisc(name: string, options: {
  22907. radius?: number;
  22908. tessellation?: number;
  22909. arc?: number;
  22910. updatable?: boolean;
  22911. sideOrientation?: number;
  22912. frontUVs?: Vector4;
  22913. backUVs?: Vector4;
  22914. }, scene?: Nullable<Scene>): Mesh;
  22915. }
  22916. }
  22917. declare module BABYLON {
  22918. /**
  22919. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  22920. *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.
  22921. * The SPS is also a particle system. It provides some methods to manage the particles.
  22922. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  22923. *
  22924. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  22925. */
  22926. export class SolidParticleSystem implements IDisposable {
  22927. /**
  22928. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  22929. * Example : var p = SPS.particles[i];
  22930. */
  22931. particles: SolidParticle[];
  22932. /**
  22933. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  22934. */
  22935. nbParticles: number;
  22936. /**
  22937. * If the particles must ever face the camera (default false). Useful for planar particles.
  22938. */
  22939. billboard: boolean;
  22940. /**
  22941. * Recompute normals when adding a shape
  22942. */
  22943. recomputeNormals: boolean;
  22944. /**
  22945. * This a counter ofr your own usage. It's not set by any SPS functions.
  22946. */
  22947. counter: number;
  22948. /**
  22949. * The SPS name. This name is also given to the underlying mesh.
  22950. */
  22951. name: string;
  22952. /**
  22953. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  22954. */
  22955. mesh: Mesh;
  22956. /**
  22957. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  22958. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  22959. */
  22960. vars: any;
  22961. /**
  22962. * This array is populated when the SPS is set as 'pickable'.
  22963. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  22964. * Each element of this array is an object `{idx: int, faceId: int}`.
  22965. * `idx` is the picked particle index in the `SPS.particles` array
  22966. * `faceId` is the picked face index counted within this particle.
  22967. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  22968. */
  22969. pickedParticles: {
  22970. idx: number;
  22971. faceId: number;
  22972. }[];
  22973. /**
  22974. * This array is populated when `enableDepthSort` is set to true.
  22975. * Each element of this array is an instance of the class DepthSortedParticle.
  22976. */
  22977. depthSortedParticles: DepthSortedParticle[];
  22978. /**
  22979. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  22980. * @hidden
  22981. */ bSphereOnly: boolean;
  22982. /**
  22983. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  22984. * @hidden
  22985. */ bSphereRadiusFactor: number;
  22986. private _scene;
  22987. private _positions;
  22988. private _indices;
  22989. private _normals;
  22990. private _colors;
  22991. private _uvs;
  22992. private _indices32;
  22993. private _positions32;
  22994. private _normals32;
  22995. private _fixedNormal32;
  22996. private _colors32;
  22997. private _uvs32;
  22998. private _index;
  22999. private _updatable;
  23000. private _pickable;
  23001. private _isVisibilityBoxLocked;
  23002. private _alwaysVisible;
  23003. private _depthSort;
  23004. private _shapeCounter;
  23005. private _copy;
  23006. private _color;
  23007. private _computeParticleColor;
  23008. private _computeParticleTexture;
  23009. private _computeParticleRotation;
  23010. private _computeParticleVertex;
  23011. private _computeBoundingBox;
  23012. private _depthSortParticles;
  23013. private _camera;
  23014. private _mustUnrotateFixedNormals;
  23015. private _particlesIntersect;
  23016. private _needs32Bits;
  23017. /**
  23018. * Creates a SPS (Solid Particle System) object.
  23019. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23020. * @param scene (Scene) is the scene in which the SPS is added.
  23021. * @param options defines the options of the sps e.g.
  23022. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23023. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23024. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23025. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23026. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23027. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23028. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23029. */
  23030. constructor(name: string, scene: Scene, options?: {
  23031. updatable?: boolean;
  23032. isPickable?: boolean;
  23033. enableDepthSort?: boolean;
  23034. particleIntersection?: boolean;
  23035. boundingSphereOnly?: boolean;
  23036. bSphereRadiusFactor?: number;
  23037. });
  23038. /**
  23039. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23040. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23041. * @returns the created mesh
  23042. */
  23043. buildMesh(): Mesh;
  23044. /**
  23045. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23046. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23047. * Thus the particles generated from `digest()` have their property `position` set yet.
  23048. * @param mesh ( Mesh ) is the mesh to be digested
  23049. * @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
  23050. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23051. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23052. * @returns the current SPS
  23053. */
  23054. digest(mesh: Mesh, options?: {
  23055. facetNb?: number;
  23056. number?: number;
  23057. delta?: number;
  23058. }): SolidParticleSystem;
  23059. private _unrotateFixedNormals;
  23060. private _resetCopy;
  23061. private _meshBuilder;
  23062. private _posToShape;
  23063. private _uvsToShapeUV;
  23064. private _addParticle;
  23065. /**
  23066. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23067. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23068. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23069. * @param nb (positive integer) the number of particles to be created from this model
  23070. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23071. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23072. * @returns the number of shapes in the system
  23073. */
  23074. addShape(mesh: Mesh, nb: number, options?: {
  23075. positionFunction?: any;
  23076. vertexFunction?: any;
  23077. }): number;
  23078. private _rebuildParticle;
  23079. /**
  23080. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23081. * @returns the SPS.
  23082. */
  23083. rebuildMesh(): SolidParticleSystem;
  23084. /**
  23085. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23086. * This method calls `updateParticle()` for each particle of the SPS.
  23087. * For an animated SPS, it is usually called within the render loop.
  23088. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23089. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23090. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23091. * @returns the SPS.
  23092. */
  23093. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23094. /**
  23095. * Disposes the SPS.
  23096. */
  23097. dispose(): void;
  23098. /**
  23099. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23100. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23101. * @returns the SPS.
  23102. */
  23103. refreshVisibleSize(): SolidParticleSystem;
  23104. /**
  23105. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23106. * @param size the size (float) of the visibility box
  23107. * note : this doesn't lock the SPS mesh bounding box.
  23108. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23109. */
  23110. setVisibilityBox(size: number): void;
  23111. /**
  23112. * Gets whether the SPS as always visible or not
  23113. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23114. */
  23115. /**
  23116. * Sets the SPS as always visible or not
  23117. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23118. */
  23119. isAlwaysVisible: boolean;
  23120. /**
  23121. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23122. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23123. */
  23124. /**
  23125. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23126. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23127. */
  23128. isVisibilityBoxLocked: boolean;
  23129. /**
  23130. * Tells to `setParticles()` to compute the particle rotations or not.
  23131. * Default value : true. The SPS is faster when it's set to false.
  23132. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23133. */
  23134. /**
  23135. * Gets if `setParticles()` computes the particle rotations or not.
  23136. * Default value : true. The SPS is faster when it's set to false.
  23137. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23138. */
  23139. computeParticleRotation: boolean;
  23140. /**
  23141. * Tells to `setParticles()` to compute the particle colors or not.
  23142. * Default value : true. The SPS is faster when it's set to false.
  23143. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23144. */
  23145. /**
  23146. * Gets if `setParticles()` computes the particle colors or not.
  23147. * Default value : true. The SPS is faster when it's set to false.
  23148. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23149. */
  23150. computeParticleColor: boolean;
  23151. /**
  23152. * Gets if `setParticles()` computes the particle textures or not.
  23153. * Default value : true. The SPS is faster when it's set to false.
  23154. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23155. */
  23156. computeParticleTexture: boolean;
  23157. /**
  23158. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23159. * Default value : false. The SPS is faster when it's set to false.
  23160. * Note : the particle custom vertex positions aren't stored values.
  23161. */
  23162. /**
  23163. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23164. * Default value : false. The SPS is faster when it's set to false.
  23165. * Note : the particle custom vertex positions aren't stored values.
  23166. */
  23167. computeParticleVertex: boolean;
  23168. /**
  23169. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23170. */
  23171. /**
  23172. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23173. */
  23174. computeBoundingBox: boolean;
  23175. /**
  23176. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23177. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23178. * Default : `true`
  23179. */
  23180. /**
  23181. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23182. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23183. * Default : `true`
  23184. */
  23185. depthSortParticles: boolean;
  23186. /**
  23187. * This function does nothing. It may be overwritten to set all the particle first values.
  23188. * The SPS doesn't call this function, you may have to call it by your own.
  23189. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23190. */
  23191. initParticles(): void;
  23192. /**
  23193. * This function does nothing. It may be overwritten to recycle a particle.
  23194. * The SPS doesn't call this function, you may have to call it by your own.
  23195. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23196. * @param particle The particle to recycle
  23197. * @returns the recycled particle
  23198. */
  23199. recycleParticle(particle: SolidParticle): SolidParticle;
  23200. /**
  23201. * Updates a particle : this function should be overwritten by the user.
  23202. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23203. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23204. * @example : just set a particle position or velocity and recycle conditions
  23205. * @param particle The particle to update
  23206. * @returns the updated particle
  23207. */
  23208. updateParticle(particle: SolidParticle): SolidParticle;
  23209. /**
  23210. * Updates a vertex of a particle : it can be overwritten by the user.
  23211. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23212. * @param particle the current particle
  23213. * @param vertex the current index of the current particle
  23214. * @param pt the index of the current vertex in the particle shape
  23215. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23216. * @example : just set a vertex particle position
  23217. * @returns the updated vertex
  23218. */
  23219. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23220. /**
  23221. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23222. * This does nothing and may be overwritten by the user.
  23223. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23224. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23225. * @param update the boolean update value actually passed to setParticles()
  23226. */
  23227. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23228. /**
  23229. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23230. * This will be passed three parameters.
  23231. * This does nothing and may be overwritten by the user.
  23232. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23233. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23234. * @param update the boolean update value actually passed to setParticles()
  23235. */
  23236. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23237. }
  23238. }
  23239. declare module BABYLON {
  23240. /**
  23241. * Represents one particle of a solid particle system.
  23242. */
  23243. export class SolidParticle {
  23244. /**
  23245. * particle global index
  23246. */
  23247. idx: number;
  23248. /**
  23249. * The color of the particle
  23250. */
  23251. color: Nullable<Color4>;
  23252. /**
  23253. * The world space position of the particle.
  23254. */
  23255. position: Vector3;
  23256. /**
  23257. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23258. */
  23259. rotation: Vector3;
  23260. /**
  23261. * The world space rotation quaternion of the particle.
  23262. */
  23263. rotationQuaternion: Nullable<Quaternion>;
  23264. /**
  23265. * The scaling of the particle.
  23266. */
  23267. scaling: Vector3;
  23268. /**
  23269. * The uvs of the particle.
  23270. */
  23271. uvs: Vector4;
  23272. /**
  23273. * The current speed of the particle.
  23274. */
  23275. velocity: Vector3;
  23276. /**
  23277. * The pivot point in the particle local space.
  23278. */
  23279. pivot: Vector3;
  23280. /**
  23281. * Must the particle be translated from its pivot point in its local space ?
  23282. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23283. * Default : false
  23284. */
  23285. translateFromPivot: boolean;
  23286. /**
  23287. * Is the particle active or not ?
  23288. */
  23289. alive: boolean;
  23290. /**
  23291. * Is the particle visible or not ?
  23292. */
  23293. isVisible: boolean;
  23294. /**
  23295. * Index of this particle in the global "positions" array (Internal use)
  23296. * @hidden
  23297. */ pos: number;
  23298. /**
  23299. * @hidden Index of this particle in the global "indices" array (Internal use)
  23300. */ ind: number;
  23301. /**
  23302. * @hidden ModelShape of this particle (Internal use)
  23303. */ model: ModelShape;
  23304. /**
  23305. * ModelShape id of this particle
  23306. */
  23307. shapeId: number;
  23308. /**
  23309. * Index of the particle in its shape id (Internal use)
  23310. */
  23311. idxInShape: number;
  23312. /**
  23313. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23314. */ modelBoundingInfo: BoundingInfo;
  23315. /**
  23316. * @hidden Particle BoundingInfo object (Internal use)
  23317. */ boundingInfo: BoundingInfo;
  23318. /**
  23319. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23320. */ sps: SolidParticleSystem;
  23321. /**
  23322. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23323. */ stillInvisible: boolean;
  23324. /**
  23325. * @hidden Last computed particle rotation matrix
  23326. */ rotationMatrix: number[];
  23327. /**
  23328. * Parent particle Id, if any.
  23329. * Default null.
  23330. */
  23331. parentId: Nullable<number>;
  23332. /**
  23333. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23334. * The possible values are :
  23335. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23336. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23337. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23338. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23339. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23340. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23341. * */
  23342. cullingStrategy: number;
  23343. /**
  23344. * @hidden Internal global position in the SPS.
  23345. */ globalPosition: Vector3;
  23346. /**
  23347. * Creates a Solid Particle object.
  23348. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23349. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23350. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23351. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23352. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23353. * @param shapeId (integer) is the model shape identifier in the SPS.
  23354. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23355. * @param sps defines the sps it is associated to
  23356. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23357. */
  23358. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23359. /**
  23360. * Legacy support, changed scale to scaling
  23361. */
  23362. /**
  23363. * Legacy support, changed scale to scaling
  23364. */
  23365. scale: Vector3;
  23366. /**
  23367. * Legacy support, changed quaternion to rotationQuaternion
  23368. */
  23369. /**
  23370. * Legacy support, changed quaternion to rotationQuaternion
  23371. */
  23372. quaternion: Nullable<Quaternion>;
  23373. /**
  23374. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23375. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23376. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23377. * @returns true if it intersects
  23378. */
  23379. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23380. /**
  23381. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23382. * A particle is in the frustum if its bounding box intersects the frustum
  23383. * @param frustumPlanes defines the frustum to test
  23384. * @returns true if the particle is in the frustum planes
  23385. */
  23386. isInFrustum(frustumPlanes: Plane[]): boolean;
  23387. /**
  23388. * get the rotation matrix of the particle
  23389. * @hidden
  23390. */
  23391. getRotationMatrix(m: Matrix): void;
  23392. }
  23393. /**
  23394. * Represents the shape of the model used by one particle of a solid particle system.
  23395. * SPS internal tool, don't use it manually.
  23396. */
  23397. export class ModelShape {
  23398. /**
  23399. * The shape id
  23400. * @hidden
  23401. */
  23402. shapeID: number;
  23403. /**
  23404. * flat array of model positions (internal use)
  23405. * @hidden
  23406. */ shape: Vector3[];
  23407. /**
  23408. * flat array of model UVs (internal use)
  23409. * @hidden
  23410. */ shapeUV: number[];
  23411. /**
  23412. * length of the shape in the model indices array (internal use)
  23413. * @hidden
  23414. */ indicesLength: number;
  23415. /**
  23416. * Custom position function (internal use)
  23417. * @hidden
  23418. */ positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23419. /**
  23420. * Custom vertex function (internal use)
  23421. * @hidden
  23422. */ vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23423. /**
  23424. * 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.
  23425. * SPS internal tool, don't use it manually.
  23426. * @hidden
  23427. */
  23428. 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>);
  23429. }
  23430. /**
  23431. * Represents a Depth Sorted Particle in the solid particle system.
  23432. */
  23433. export class DepthSortedParticle {
  23434. /**
  23435. * Index of the particle in the "indices" array
  23436. */
  23437. ind: number;
  23438. /**
  23439. * Length of the particle shape in the "indices" array
  23440. */
  23441. indicesLength: number;
  23442. /**
  23443. * Squared distance from the particle to the camera
  23444. */
  23445. sqDistance: number;
  23446. }
  23447. }
  23448. declare module BABYLON {
  23449. /**
  23450. * Class used to store all common mesh properties
  23451. */
  23452. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23453. /** No occlusion */
  23454. static OCCLUSION_TYPE_NONE: number;
  23455. /** Occlusion set to optimisitic */
  23456. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23457. /** Occlusion set to strict */
  23458. static OCCLUSION_TYPE_STRICT: number;
  23459. /** Use an accurante occlusion algorithm */
  23460. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23461. /** Use a conservative occlusion algorithm */
  23462. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23463. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23464. * Test order :
  23465. * Is the bounding sphere outside the frustum ?
  23466. * If not, are the bounding box vertices outside the frustum ?
  23467. * It not, then the cullable object is in the frustum.
  23468. */
  23469. static readonly CULLINGSTRATEGY_STANDARD: number;
  23470. /** Culling strategy : Bounding Sphere Only.
  23471. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23472. * It's also less accurate than the standard because some not visible objects can still be selected.
  23473. * Test : is the bounding sphere outside the frustum ?
  23474. * If not, then the cullable object is in the frustum.
  23475. */
  23476. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23477. /** Culling strategy : Optimistic Inclusion.
  23478. * This in an inclusion test first, then the standard exclusion test.
  23479. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23480. * 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.
  23481. * Anyway, it's as accurate as the standard strategy.
  23482. * Test :
  23483. * Is the cullable object bounding sphere center in the frustum ?
  23484. * If not, apply the default culling strategy.
  23485. */
  23486. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23487. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23488. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23489. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23490. * 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.
  23491. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23492. * Test :
  23493. * Is the cullable object bounding sphere center in the frustum ?
  23494. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23495. */
  23496. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23497. /**
  23498. * No billboard
  23499. */
  23500. static readonly BILLBOARDMODE_NONE: number;
  23501. /** Billboard on X axis */
  23502. static readonly BILLBOARDMODE_X: number;
  23503. /** Billboard on Y axis */
  23504. static readonly BILLBOARDMODE_Y: number;
  23505. /** Billboard on Z axis */
  23506. static readonly BILLBOARDMODE_Z: number;
  23507. /** Billboard on all axes */
  23508. static readonly BILLBOARDMODE_ALL: number;
  23509. private _facetData;
  23510. /**
  23511. * The culling strategy to use to check whether the mesh must be rendered or not.
  23512. * This value can be changed at any time and will be used on the next render mesh selection.
  23513. * The possible values are :
  23514. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23515. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23516. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23517. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23518. * Please read each static variable documentation to get details about the culling process.
  23519. * */
  23520. cullingStrategy: number;
  23521. /**
  23522. * Gets the number of facets in the mesh
  23523. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23524. */
  23525. readonly facetNb: number;
  23526. /**
  23527. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23528. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23529. */
  23530. partitioningSubdivisions: number;
  23531. /**
  23532. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23533. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23534. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23535. */
  23536. partitioningBBoxRatio: number;
  23537. /**
  23538. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23539. * Works only for updatable meshes.
  23540. * Doesn't work with multi-materials
  23541. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23542. */
  23543. mustDepthSortFacets: boolean;
  23544. /**
  23545. * The location (Vector3) where the facet depth sort must be computed from.
  23546. * By default, the active camera position.
  23547. * Used only when facet depth sort is enabled
  23548. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23549. */
  23550. facetDepthSortFrom: Vector3;
  23551. /**
  23552. * gets a boolean indicating if facetData is enabled
  23553. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23554. */
  23555. readonly isFacetDataEnabled: boolean;
  23556. /** @hidden */ updateNonUniformScalingState(value: boolean): boolean;
  23557. /**
  23558. * An event triggered when this mesh collides with another one
  23559. */
  23560. onCollideObservable: Observable<AbstractMesh>;
  23561. private _onCollideObserver;
  23562. /** Set a function to call when this mesh collides with another one */
  23563. onCollide: () => void;
  23564. /**
  23565. * An event triggered when the collision's position changes
  23566. */
  23567. onCollisionPositionChangeObservable: Observable<Vector3>;
  23568. private _onCollisionPositionChangeObserver;
  23569. /** Set a function to call when the collision's position changes */
  23570. onCollisionPositionChange: () => void;
  23571. /**
  23572. * An event triggered when material is changed
  23573. */
  23574. onMaterialChangedObservable: Observable<AbstractMesh>;
  23575. /**
  23576. * Gets or sets the orientation for POV movement & rotation
  23577. */
  23578. definedFacingForward: boolean;
  23579. /** @hidden */ occlusionQuery: Nullable<WebGLQuery>;
  23580. private _visibility;
  23581. /** @hidden */ isActive: boolean;
  23582. /** @hidden */ renderingGroup: RenderingGroup;
  23583. /**
  23584. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23585. */
  23586. /**
  23587. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23588. */
  23589. visibility: number;
  23590. /** Gets or sets the alpha index used to sort transparent meshes
  23591. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23592. */
  23593. alphaIndex: number;
  23594. /**
  23595. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23596. */
  23597. isVisible: boolean;
  23598. /**
  23599. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23600. */
  23601. isPickable: boolean;
  23602. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23603. showSubMeshesBoundingBox: boolean;
  23604. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23605. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23606. */
  23607. isBlocker: boolean;
  23608. /**
  23609. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  23610. */
  23611. enablePointerMoveEvents: boolean;
  23612. /**
  23613. * Specifies the rendering group id for this mesh (0 by default)
  23614. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23615. */
  23616. renderingGroupId: number;
  23617. private _material;
  23618. /** Gets or sets current material */
  23619. material: Nullable<Material>;
  23620. private _receiveShadows;
  23621. /**
  23622. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  23623. * @see http://doc.babylonjs.com/babylon101/shadows
  23624. */
  23625. receiveShadows: boolean;
  23626. /** Defines color to use when rendering outline */
  23627. outlineColor: Color3;
  23628. /** Define width to use when rendering outline */
  23629. outlineWidth: number;
  23630. /** Defines color to use when rendering overlay */
  23631. overlayColor: Color3;
  23632. /** Defines alpha to use when rendering overlay */
  23633. overlayAlpha: number;
  23634. private _hasVertexAlpha;
  23635. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  23636. hasVertexAlpha: boolean;
  23637. private _useVertexColors;
  23638. /** 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) */
  23639. useVertexColors: boolean;
  23640. private _computeBonesUsingShaders;
  23641. /**
  23642. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  23643. */
  23644. computeBonesUsingShaders: boolean;
  23645. private _numBoneInfluencers;
  23646. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  23647. numBoneInfluencers: number;
  23648. private _applyFog;
  23649. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  23650. applyFog: boolean;
  23651. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  23652. useOctreeForRenderingSelection: boolean;
  23653. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  23654. useOctreeForPicking: boolean;
  23655. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  23656. useOctreeForCollisions: boolean;
  23657. private _layerMask;
  23658. /**
  23659. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  23660. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  23661. */
  23662. layerMask: number;
  23663. /**
  23664. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  23665. */
  23666. alwaysSelectAsActiveMesh: boolean;
  23667. /**
  23668. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  23669. */
  23670. doNotSyncBoundingInfo: boolean;
  23671. /**
  23672. * Gets or sets the current action manager
  23673. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  23674. */
  23675. actionManager: Nullable<AbstractActionManager>;
  23676. private _checkCollisions;
  23677. private _collisionMask;
  23678. private _collisionGroup;
  23679. /**
  23680. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  23681. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23682. */
  23683. ellipsoid: Vector3;
  23684. /**
  23685. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  23686. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23687. */
  23688. ellipsoidOffset: Vector3;
  23689. private _collider;
  23690. private _oldPositionForCollisions;
  23691. private _diffPositionForCollisions;
  23692. /**
  23693. * Gets or sets a collision mask used to mask collisions (default is -1).
  23694. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23695. */
  23696. collisionMask: number;
  23697. /**
  23698. * Gets or sets the current collision group mask (-1 by default).
  23699. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23700. */
  23701. collisionGroup: number;
  23702. /**
  23703. * Defines edge width used when edgesRenderer is enabled
  23704. * @see https://www.babylonjs-playground.com/#10OJSG#13
  23705. */
  23706. edgesWidth: number;
  23707. /**
  23708. * Defines edge color used when edgesRenderer is enabled
  23709. * @see https://www.babylonjs-playground.com/#10OJSG#13
  23710. */
  23711. edgesColor: Color4;
  23712. /** @hidden */ edgesRenderer: Nullable<IEdgesRenderer>;
  23713. /** @hidden */ masterMesh: Nullable<AbstractMesh>;
  23714. /** @hidden */ boundingInfo: Nullable<BoundingInfo>;
  23715. /** @hidden */ renderId: number;
  23716. /**
  23717. * Gets or sets the list of subMeshes
  23718. * @see http://doc.babylonjs.com/how_to/multi_materials
  23719. */
  23720. subMeshes: SubMesh[];
  23721. /** @hidden */ intersectionsInProgress: AbstractMesh[];
  23722. /** @hidden */ unIndexed: boolean;
  23723. /** @hidden */ lightSources: Light[];
  23724. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  23725. /** @hidden */ waitingActions: any;
  23726. /** @hidden */ waitingFreezeWorldMatrix: Nullable<boolean>;
  23727. private _skeleton;
  23728. /** @hidden */ bonesTransformMatrices: Nullable<Float32Array>;
  23729. /**
  23730. * Gets or sets a skeleton to apply skining transformations
  23731. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  23732. */
  23733. skeleton: Nullable<Skeleton>;
  23734. /**
  23735. * An event triggered when the mesh is rebuilt.
  23736. */
  23737. onRebuildObservable: Observable<AbstractMesh>;
  23738. /**
  23739. * Creates a new AbstractMesh
  23740. * @param name defines the name of the mesh
  23741. * @param scene defines the hosting scene
  23742. */
  23743. constructor(name: string, scene?: Nullable<Scene>);
  23744. /**
  23745. * Returns the string "AbstractMesh"
  23746. * @returns "AbstractMesh"
  23747. */
  23748. getClassName(): string;
  23749. /**
  23750. * Gets a string representation of the current mesh
  23751. * @param fullDetails defines a boolean indicating if full details must be included
  23752. * @returns a string representation of the current mesh
  23753. */
  23754. toString(fullDetails?: boolean): string;
  23755. /**
  23756. * @hidden
  23757. */
  23758. protected _getEffectiveParent(): Nullable<Node>;
  23759. /** @hidden */ getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  23760. /** @hidden */ rebuild(): void;
  23761. /** @hidden */ resyncLightSources(): void;
  23762. /** @hidden */ resyncLighSource(light: Light): void;
  23763. /** @hidden */ unBindEffect(): void;
  23764. /** @hidden */ removeLightSource(light: Light): void;
  23765. private _markSubMeshesAsDirty;
  23766. /** @hidden */ markSubMeshesAsLightDirty(): void;
  23767. /** @hidden */ markSubMeshesAsAttributesDirty(): void;
  23768. /** @hidden */ markSubMeshesAsMiscDirty(): void;
  23769. /**
  23770. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  23771. */
  23772. scaling: Vector3;
  23773. /**
  23774. * Returns true if the mesh is blocked. Implemented by child classes
  23775. */
  23776. readonly isBlocked: boolean;
  23777. /**
  23778. * Returns the mesh itself by default. Implemented by child classes
  23779. * @param camera defines the camera to use to pick the right LOD level
  23780. * @returns the currentAbstractMesh
  23781. */
  23782. getLOD(camera: Camera): Nullable<AbstractMesh>;
  23783. /**
  23784. * Returns 0 by default. Implemented by child classes
  23785. * @returns an integer
  23786. */
  23787. getTotalVertices(): number;
  23788. /**
  23789. * Returns a positive integer : the total number of indices in this mesh geometry.
  23790. * @returns the numner of indices or zero if the mesh has no geometry.
  23791. */
  23792. getTotalIndices(): number;
  23793. /**
  23794. * Returns null by default. Implemented by child classes
  23795. * @returns null
  23796. */
  23797. getIndices(): Nullable<IndicesArray>;
  23798. /**
  23799. * Returns the array of the requested vertex data kind. Implemented by child classes
  23800. * @param kind defines the vertex data kind to use
  23801. * @returns null
  23802. */
  23803. getVerticesData(kind: string): Nullable<FloatArray>;
  23804. /**
  23805. * Sets the vertex data of the mesh geometry for the requested `kind`.
  23806. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  23807. * Note that a new underlying VertexBuffer object is created each call.
  23808. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  23809. * @param kind defines vertex data kind:
  23810. * * VertexBuffer.PositionKind
  23811. * * VertexBuffer.UVKind
  23812. * * VertexBuffer.UV2Kind
  23813. * * VertexBuffer.UV3Kind
  23814. * * VertexBuffer.UV4Kind
  23815. * * VertexBuffer.UV5Kind
  23816. * * VertexBuffer.UV6Kind
  23817. * * VertexBuffer.ColorKind
  23818. * * VertexBuffer.MatricesIndicesKind
  23819. * * VertexBuffer.MatricesIndicesExtraKind
  23820. * * VertexBuffer.MatricesWeightsKind
  23821. * * VertexBuffer.MatricesWeightsExtraKind
  23822. * @param data defines the data source
  23823. * @param updatable defines if the data must be flagged as updatable (or static)
  23824. * @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
  23825. * @returns the current mesh
  23826. */
  23827. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23828. /**
  23829. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  23830. * If the mesh has no geometry, it is simply returned as it is.
  23831. * @param kind defines vertex data kind:
  23832. * * VertexBuffer.PositionKind
  23833. * * VertexBuffer.UVKind
  23834. * * VertexBuffer.UV2Kind
  23835. * * VertexBuffer.UV3Kind
  23836. * * VertexBuffer.UV4Kind
  23837. * * VertexBuffer.UV5Kind
  23838. * * VertexBuffer.UV6Kind
  23839. * * VertexBuffer.ColorKind
  23840. * * VertexBuffer.MatricesIndicesKind
  23841. * * VertexBuffer.MatricesIndicesExtraKind
  23842. * * VertexBuffer.MatricesWeightsKind
  23843. * * VertexBuffer.MatricesWeightsExtraKind
  23844. * @param data defines the data source
  23845. * @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
  23846. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  23847. * @returns the current mesh
  23848. */
  23849. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23850. /**
  23851. * Sets the mesh indices,
  23852. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  23853. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  23854. * @param totalVertices Defines the total number of vertices
  23855. * @returns the current mesh
  23856. */
  23857. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  23858. /**
  23859. * Gets a boolean indicating if specific vertex data is present
  23860. * @param kind defines the vertex data kind to use
  23861. * @returns true is data kind is present
  23862. */
  23863. isVerticesDataPresent(kind: string): boolean;
  23864. /**
  23865. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  23866. * @returns a BoundingInfo
  23867. */
  23868. getBoundingInfo(): BoundingInfo;
  23869. /**
  23870. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  23871. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  23872. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  23873. * @returns the current mesh
  23874. */
  23875. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  23876. /**
  23877. * Overwrite the current bounding info
  23878. * @param boundingInfo defines the new bounding info
  23879. * @returns the current mesh
  23880. */
  23881. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  23882. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  23883. readonly useBones: boolean;
  23884. /** @hidden */ preActivate(): void;
  23885. /** @hidden */ preActivateForIntermediateRendering(renderId: number): void;
  23886. /** @hidden */ activate(renderId: number): boolean;
  23887. /** @hidden */ freeze(): void;
  23888. /** @hidden */ unFreeze(): void;
  23889. /**
  23890. * Gets the current world matrix
  23891. * @returns a Matrix
  23892. */
  23893. getWorldMatrix(): Matrix;
  23894. /** @hidden */ getWorldMatrixDeterminant(): number;
  23895. /**
  23896. * Perform relative position change from the point of view of behind the front of the mesh.
  23897. * This is performed taking into account the meshes current rotation, so you do not have to care.
  23898. * Supports definition of mesh facing forward or backward
  23899. * @param amountRight defines the distance on the right axis
  23900. * @param amountUp defines the distance on the up axis
  23901. * @param amountForward defines the distance on the forward axis
  23902. * @returns the current mesh
  23903. */
  23904. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  23905. /**
  23906. * Calculate relative position change from the point of view of behind the front of the mesh.
  23907. * This is performed taking into account the meshes current rotation, so you do not have to care.
  23908. * Supports definition of mesh facing forward or backward
  23909. * @param amountRight defines the distance on the right axis
  23910. * @param amountUp defines the distance on the up axis
  23911. * @param amountForward defines the distance on the forward axis
  23912. * @returns the new displacement vector
  23913. */
  23914. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  23915. /**
  23916. * Perform relative rotation change from the point of view of behind the front of the mesh.
  23917. * Supports definition of mesh facing forward or backward
  23918. * @param flipBack defines the flip
  23919. * @param twirlClockwise defines the twirl
  23920. * @param tiltRight defines the tilt
  23921. * @returns the current mesh
  23922. */
  23923. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  23924. /**
  23925. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  23926. * Supports definition of mesh facing forward or backward.
  23927. * @param flipBack defines the flip
  23928. * @param twirlClockwise defines the twirl
  23929. * @param tiltRight defines the tilt
  23930. * @returns the new rotation vector
  23931. */
  23932. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  23933. /**
  23934. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  23935. * @param includeDescendants Include bounding info from descendants as well (true by default)
  23936. * @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
  23937. * @returns the new bounding vectors
  23938. */
  23939. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  23940. min: Vector3;
  23941. max: Vector3;
  23942. };
  23943. /**
  23944. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23945. * This means the mesh underlying bounding box and sphere are recomputed.
  23946. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23947. * @returns the current mesh
  23948. */
  23949. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  23950. /** @hidden */ refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  23951. /** @hidden */ getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  23952. /** @hidden */ updateBoundingInfo(): AbstractMesh;
  23953. /** @hidden */ updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  23954. /** @hidden */
  23955. protected _afterComputeWorldMatrix(): void;
  23956. /** @hidden */ protected readonly _effectiveMesh: AbstractMesh;
  23957. /**
  23958. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23959. * A mesh is in the frustum if its bounding box intersects the frustum
  23960. * @param frustumPlanes defines the frustum to test
  23961. * @returns true if the mesh is in the frustum planes
  23962. */
  23963. isInFrustum(frustumPlanes: Plane[]): boolean;
  23964. /**
  23965. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  23966. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  23967. * @param frustumPlanes defines the frustum to test
  23968. * @returns true if the mesh is completely in the frustum planes
  23969. */
  23970. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23971. /**
  23972. * True if the mesh intersects another mesh or a SolidParticle object
  23973. * @param mesh defines a target mesh or SolidParticle to test
  23974. * @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)
  23975. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  23976. * @returns true if there is an intersection
  23977. */
  23978. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  23979. /**
  23980. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  23981. * @param point defines the point to test
  23982. * @returns true if there is an intersection
  23983. */
  23984. intersectsPoint(point: Vector3): boolean;
  23985. /**
  23986. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  23987. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23988. */
  23989. checkCollisions: boolean;
  23990. /**
  23991. * Gets Collider object used to compute collisions (not physics)
  23992. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23993. */
  23994. readonly collider: Collider;
  23995. /**
  23996. * Move the mesh using collision engine
  23997. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23998. * @param displacement defines the requested displacement vector
  23999. * @returns the current mesh
  24000. */
  24001. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24002. private _onCollisionPositionChange;
  24003. /** @hidden */ collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24004. /** @hidden */ processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24005. /** @hidden */ checkCollision(collider: Collider): AbstractMesh;
  24006. /** @hidden */ generatePointsArray(): boolean;
  24007. /**
  24008. * Checks if the passed Ray intersects with the mesh
  24009. * @param ray defines the ray to use
  24010. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24011. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24012. * @returns the picking info
  24013. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24014. */
  24015. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24016. /**
  24017. * Clones the current mesh
  24018. * @param name defines the mesh name
  24019. * @param newParent defines the new mesh parent
  24020. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24021. * @returns the new mesh
  24022. */
  24023. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24024. /**
  24025. * Disposes all the submeshes of the current meshnp
  24026. * @returns the current mesh
  24027. */
  24028. releaseSubMeshes(): AbstractMesh;
  24029. /**
  24030. * Releases resources associated with this abstract mesh.
  24031. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24032. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24033. */
  24034. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24035. /**
  24036. * Adds the passed mesh as a child to the current mesh
  24037. * @param mesh defines the child mesh
  24038. * @returns the current mesh
  24039. */
  24040. addChild(mesh: AbstractMesh): AbstractMesh;
  24041. /**
  24042. * Removes the passed mesh from the current mesh children list
  24043. * @param mesh defines the child mesh
  24044. * @returns the current mesh
  24045. */
  24046. removeChild(mesh: AbstractMesh): AbstractMesh;
  24047. /** @hidden */
  24048. private _initFacetData;
  24049. /**
  24050. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24051. * This method can be called within the render loop.
  24052. * 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
  24053. * @returns the current mesh
  24054. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24055. */
  24056. updateFacetData(): AbstractMesh;
  24057. /**
  24058. * Returns the facetLocalNormals array.
  24059. * The normals are expressed in the mesh local spac
  24060. * @returns an array of Vector3
  24061. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24062. */
  24063. getFacetLocalNormals(): Vector3[];
  24064. /**
  24065. * Returns the facetLocalPositions array.
  24066. * The facet positions are expressed in the mesh local space
  24067. * @returns an array of Vector3
  24068. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24069. */
  24070. getFacetLocalPositions(): Vector3[];
  24071. /**
  24072. * Returns the facetLocalPartioning array
  24073. * @returns an array of array of numbers
  24074. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24075. */
  24076. getFacetLocalPartitioning(): number[][];
  24077. /**
  24078. * Returns the i-th facet position in the world system.
  24079. * This method allocates a new Vector3 per call
  24080. * @param i defines the facet index
  24081. * @returns a new Vector3
  24082. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24083. */
  24084. getFacetPosition(i: number): Vector3;
  24085. /**
  24086. * Sets the reference Vector3 with the i-th facet position in the world system
  24087. * @param i defines the facet index
  24088. * @param ref defines the target vector
  24089. * @returns the current mesh
  24090. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24091. */
  24092. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24093. /**
  24094. * Returns the i-th facet normal in the world system.
  24095. * This method allocates a new Vector3 per call
  24096. * @param i defines the facet index
  24097. * @returns a new Vector3
  24098. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24099. */
  24100. getFacetNormal(i: number): Vector3;
  24101. /**
  24102. * Sets the reference Vector3 with the i-th facet normal in the world system
  24103. * @param i defines the facet index
  24104. * @param ref defines the target vector
  24105. * @returns the current mesh
  24106. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24107. */
  24108. getFacetNormalToRef(i: number, ref: Vector3): this;
  24109. /**
  24110. * 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)
  24111. * @param x defines x coordinate
  24112. * @param y defines y coordinate
  24113. * @param z defines z coordinate
  24114. * @returns the array of facet indexes
  24115. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24116. */
  24117. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24118. /**
  24119. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24120. * @param projected sets as the (x,y,z) world projection on the facet
  24121. * @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
  24122. * @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
  24123. * @param x defines x coordinate
  24124. * @param y defines y coordinate
  24125. * @param z defines z coordinate
  24126. * @returns the face index if found (or null instead)
  24127. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24128. */
  24129. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24130. /**
  24131. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24132. * @param projected sets as the (x,y,z) local projection on the facet
  24133. * @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
  24134. * @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
  24135. * @param x defines x coordinate
  24136. * @param y defines y coordinate
  24137. * @param z defines z coordinate
  24138. * @returns the face index if found (or null instead)
  24139. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24140. */
  24141. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24142. /**
  24143. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24144. * @returns the parameters
  24145. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24146. */
  24147. getFacetDataParameters(): any;
  24148. /**
  24149. * Disables the feature FacetData and frees the related memory
  24150. * @returns the current mesh
  24151. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24152. */
  24153. disableFacetData(): AbstractMesh;
  24154. /**
  24155. * Updates the AbstractMesh indices array
  24156. * @param indices defines the data source
  24157. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24158. * @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)
  24159. * @returns the current mesh
  24160. */
  24161. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24162. /**
  24163. * Creates new normals data for the mesh
  24164. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24165. * @returns the current mesh
  24166. */
  24167. createNormals(updatable: boolean): AbstractMesh;
  24168. /**
  24169. * Align the mesh with a normal
  24170. * @param normal defines the normal to use
  24171. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24172. * @returns the current mesh
  24173. */
  24174. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24175. /** @hidden */ checkOcclusionQuery(): boolean;
  24176. }
  24177. }
  24178. declare module BABYLON {
  24179. /**
  24180. * Interface used to define ActionEvent
  24181. */
  24182. export interface IActionEvent {
  24183. /** The mesh or sprite that triggered the action */
  24184. source: any;
  24185. /** The X mouse cursor position at the time of the event */
  24186. pointerX: number;
  24187. /** The Y mouse cursor position at the time of the event */
  24188. pointerY: number;
  24189. /** The mesh that is currently pointed at (can be null) */
  24190. meshUnderPointer: Nullable<AbstractMesh>;
  24191. /** the original (browser) event that triggered the ActionEvent */
  24192. sourceEvent?: any;
  24193. /** additional data for the event */
  24194. additionalData?: any;
  24195. }
  24196. /**
  24197. * ActionEvent is the event being sent when an action is triggered.
  24198. */
  24199. export class ActionEvent implements IActionEvent {
  24200. /** The mesh or sprite that triggered the action */
  24201. source: any;
  24202. /** The X mouse cursor position at the time of the event */
  24203. pointerX: number;
  24204. /** The Y mouse cursor position at the time of the event */
  24205. pointerY: number;
  24206. /** The mesh that is currently pointed at (can be null) */
  24207. meshUnderPointer: Nullable<AbstractMesh>;
  24208. /** the original (browser) event that triggered the ActionEvent */
  24209. sourceEvent?: any;
  24210. /** additional data for the event */
  24211. additionalData?: any;
  24212. /**
  24213. * Creates a new ActionEvent
  24214. * @param source The mesh or sprite that triggered the action
  24215. * @param pointerX The X mouse cursor position at the time of the event
  24216. * @param pointerY The Y mouse cursor position at the time of the event
  24217. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24218. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24219. * @param additionalData additional data for the event
  24220. */
  24221. constructor(
  24222. /** The mesh or sprite that triggered the action */
  24223. source: any,
  24224. /** The X mouse cursor position at the time of the event */
  24225. pointerX: number,
  24226. /** The Y mouse cursor position at the time of the event */
  24227. pointerY: number,
  24228. /** The mesh that is currently pointed at (can be null) */
  24229. meshUnderPointer: Nullable<AbstractMesh>,
  24230. /** the original (browser) event that triggered the ActionEvent */
  24231. sourceEvent?: any,
  24232. /** additional data for the event */
  24233. additionalData?: any);
  24234. /**
  24235. * Helper function to auto-create an ActionEvent from a source mesh.
  24236. * @param source The source mesh that triggered the event
  24237. * @param evt The original (browser) event
  24238. * @param additionalData additional data for the event
  24239. * @returns the new ActionEvent
  24240. */
  24241. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24242. /**
  24243. * Helper function to auto-create an ActionEvent from a source sprite
  24244. * @param source The source sprite that triggered the event
  24245. * @param scene Scene associated with the sprite
  24246. * @param evt The original (browser) event
  24247. * @param additionalData additional data for the event
  24248. * @returns the new ActionEvent
  24249. */
  24250. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24251. /**
  24252. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24253. * @param scene the scene where the event occurred
  24254. * @param evt The original (browser) event
  24255. * @returns the new ActionEvent
  24256. */
  24257. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24258. /**
  24259. * Helper function to auto-create an ActionEvent from a primitive
  24260. * @param prim defines the target primitive
  24261. * @param pointerPos defines the pointer position
  24262. * @param evt The original (browser) event
  24263. * @param additionalData additional data for the event
  24264. * @returns the new ActionEvent
  24265. */
  24266. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24267. }
  24268. }
  24269. declare module BABYLON {
  24270. /**
  24271. * Abstract class used to decouple action Manager from scene and meshes.
  24272. * Do not instantiate.
  24273. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24274. */
  24275. export abstract class AbstractActionManager implements IDisposable {
  24276. /** Gets the list of active triggers */
  24277. static Triggers: {
  24278. [key: string]: number;
  24279. };
  24280. /** Gets the cursor to use when hovering items */
  24281. hoverCursor: string;
  24282. /** Gets the list of actions */
  24283. actions: IAction[];
  24284. /**
  24285. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24286. */
  24287. isRecursive: boolean;
  24288. /**
  24289. * Releases all associated resources
  24290. */
  24291. abstract dispose(): void;
  24292. /**
  24293. * Does this action manager has pointer triggers
  24294. */
  24295. abstract readonly hasPointerTriggers: boolean;
  24296. /**
  24297. * Does this action manager has pick triggers
  24298. */
  24299. abstract readonly hasPickTriggers: boolean;
  24300. /**
  24301. * Process a specific trigger
  24302. * @param trigger defines the trigger to process
  24303. * @param evt defines the event details to be processed
  24304. */
  24305. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24306. /**
  24307. * Does this action manager handles actions of any of the given triggers
  24308. * @param triggers defines the triggers to be tested
  24309. * @return a boolean indicating whether one (or more) of the triggers is handled
  24310. */
  24311. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24312. /**
  24313. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24314. * speed.
  24315. * @param triggerA defines the trigger to be tested
  24316. * @param triggerB defines the trigger to be tested
  24317. * @return a boolean indicating whether one (or more) of the triggers is handled
  24318. */
  24319. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24320. /**
  24321. * Does this action manager handles actions of a given trigger
  24322. * @param trigger defines the trigger to be tested
  24323. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24324. * @return whether the trigger is handled
  24325. */
  24326. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24327. /**
  24328. * Serialize this manager to a JSON object
  24329. * @param name defines the property name to store this manager
  24330. * @returns a JSON representation of this manager
  24331. */
  24332. abstract serialize(name: string): any;
  24333. /**
  24334. * Registers an action to this action manager
  24335. * @param action defines the action to be registered
  24336. * @return the action amended (prepared) after registration
  24337. */
  24338. abstract registerAction(action: IAction): Nullable<IAction>;
  24339. /**
  24340. * Unregisters an action to this action manager
  24341. * @param action defines the action to be unregistered
  24342. * @return a boolean indicating whether the action has been unregistered
  24343. */
  24344. abstract unregisterAction(action: IAction): Boolean;
  24345. /**
  24346. * Does exist one action manager with at least one trigger
  24347. **/
  24348. static readonly HasTriggers: boolean;
  24349. /**
  24350. * Does exist one action manager with at least one pick trigger
  24351. **/
  24352. static readonly HasPickTriggers: boolean;
  24353. /**
  24354. * Does exist one action manager that handles actions of a given trigger
  24355. * @param trigger defines the trigger to be tested
  24356. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24357. **/
  24358. static HasSpecificTrigger(trigger: number): boolean;
  24359. }
  24360. }
  24361. declare module BABYLON {
  24362. /**
  24363. * Defines how a node can be built from a string name.
  24364. */
  24365. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24366. /**
  24367. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24368. */
  24369. export class Node implements IBehaviorAware<Node> {
  24370. /** @hidden */ private static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  24371. private static _NodeConstructors;
  24372. /**
  24373. * Add a new node constructor
  24374. * @param type defines the type name of the node to construct
  24375. * @param constructorFunc defines the constructor function
  24376. */
  24377. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24378. /**
  24379. * Returns a node constructor based on type name
  24380. * @param type defines the type name
  24381. * @param name defines the new node name
  24382. * @param scene defines the hosting scene
  24383. * @param options defines optional options to transmit to constructors
  24384. * @returns the new constructor or null
  24385. */
  24386. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24387. /**
  24388. * Gets or sets the name of the node
  24389. */
  24390. name: string;
  24391. /**
  24392. * Gets or sets the id of the node
  24393. */
  24394. id: string;
  24395. /**
  24396. * Gets or sets the unique id of the node
  24397. */
  24398. uniqueId: number;
  24399. /**
  24400. * Gets or sets a string used to store user defined state for the node
  24401. */
  24402. state: string;
  24403. /**
  24404. * Gets or sets an object used to store user defined information for the node
  24405. */
  24406. metadata: any;
  24407. /**
  24408. * For internal use only. Please do not use.
  24409. */
  24410. reservedDataStore: any;
  24411. /**
  24412. * List of inspectable custom properties (used by the Inspector)
  24413. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24414. */
  24415. inspectableCustomProperties: IInspectable[];
  24416. /**
  24417. * Gets or sets a boolean used to define if the node must be serialized
  24418. */
  24419. doNotSerialize: boolean;
  24420. /** @hidden */ isDisposed: boolean;
  24421. /**
  24422. * Gets a list of Animations associated with the node
  24423. */
  24424. animations: Animation[];
  24425. protected _ranges: {
  24426. [name: string]: Nullable<AnimationRange>;
  24427. };
  24428. /**
  24429. * Callback raised when the node is ready to be used
  24430. */
  24431. onReady: (node: Node) => void;
  24432. private _isEnabled;
  24433. private _isParentEnabled;
  24434. private _isReady;
  24435. /** @hidden */ currentRenderId: number;
  24436. private _parentUpdateId;
  24437. protected _childUpdateId: number;
  24438. /** @hidden */ waitingParentId: Nullable<string>;
  24439. /** @hidden */ scene: Scene;
  24440. /** @hidden */ cache: any;
  24441. private _parentNode;
  24442. private _children;
  24443. /** @hidden */ worldMatrix: Matrix;
  24444. /** @hidden */ worldMatrixDeterminant: number;
  24445. /** @hidden */ worldMatrixDeterminantIsDirty: boolean;
  24446. /** @hidden */
  24447. private _sceneRootNodesIndex;
  24448. /**
  24449. * Gets a boolean indicating if the node has been disposed
  24450. * @returns true if the node was disposed
  24451. */
  24452. isDisposed(): boolean;
  24453. /**
  24454. * Gets or sets the parent of the node (without keeping the current position in the scene)
  24455. * @see https://doc.babylonjs.com/how_to/parenting
  24456. */
  24457. parent: Nullable<Node>;
  24458. private addToSceneRootNodes;
  24459. private removeFromSceneRootNodes;
  24460. private _animationPropertiesOverride;
  24461. /**
  24462. * Gets or sets the animation properties override
  24463. */
  24464. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24465. /**
  24466. * Gets a string idenfifying the name of the class
  24467. * @returns "Node" string
  24468. */
  24469. getClassName(): string;
  24470. /** @hidden */ protected readonly _isNode: boolean;
  24471. /**
  24472. * An event triggered when the mesh is disposed
  24473. */
  24474. onDisposeObservable: Observable<Node>;
  24475. private _onDisposeObserver;
  24476. /**
  24477. * Sets a callback that will be raised when the node will be disposed
  24478. */
  24479. onDispose: () => void;
  24480. /**
  24481. * Creates a new Node
  24482. * @param name the name and id to be given to this node
  24483. * @param scene the scene this node will be added to
  24484. * @param addToRootNodes the node will be added to scene.rootNodes
  24485. */
  24486. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24487. /**
  24488. * Gets the scene of the node
  24489. * @returns a scene
  24490. */
  24491. getScene(): Scene;
  24492. /**
  24493. * Gets the engine of the node
  24494. * @returns a Engine
  24495. */
  24496. getEngine(): Engine;
  24497. private _behaviors;
  24498. /**
  24499. * Attach a behavior to the node
  24500. * @see http://doc.babylonjs.com/features/behaviour
  24501. * @param behavior defines the behavior to attach
  24502. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24503. * @returns the current Node
  24504. */
  24505. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24506. /**
  24507. * Remove an attached behavior
  24508. * @see http://doc.babylonjs.com/features/behaviour
  24509. * @param behavior defines the behavior to attach
  24510. * @returns the current Node
  24511. */
  24512. removeBehavior(behavior: Behavior<Node>): Node;
  24513. /**
  24514. * Gets the list of attached behaviors
  24515. * @see http://doc.babylonjs.com/features/behaviour
  24516. */
  24517. readonly behaviors: Behavior<Node>[];
  24518. /**
  24519. * Gets an attached behavior by name
  24520. * @param name defines the name of the behavior to look for
  24521. * @see http://doc.babylonjs.com/features/behaviour
  24522. * @returns null if behavior was not found else the requested behavior
  24523. */
  24524. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24525. /**
  24526. * Returns the latest update of the World matrix
  24527. * @returns a Matrix
  24528. */
  24529. getWorldMatrix(): Matrix;
  24530. /** @hidden */ getWorldMatrixDeterminant(): number;
  24531. /**
  24532. * Returns directly the latest state of the mesh World matrix.
  24533. * A Matrix is returned.
  24534. */
  24535. readonly worldMatrixFromCache: Matrix;
  24536. /** @hidden */ initCache(): void;
  24537. /** @hidden */
  24538. updateCache(force?: boolean): void;
  24539. /** @hidden */ getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24540. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  24541. /** @hidden */ isSynchronized(): boolean;
  24542. /** @hidden */ markSyncedWithParent(): void;
  24543. /** @hidden */
  24544. isSynchronizedWithParent(): boolean;
  24545. /** @hidden */
  24546. isSynchronized(): boolean;
  24547. /**
  24548. * Is this node ready to be used/rendered
  24549. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24550. * @return true if the node is ready
  24551. */
  24552. isReady(completeCheck?: boolean): boolean;
  24553. /**
  24554. * Is this node enabled?
  24555. * 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
  24556. * @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
  24557. * @return whether this node (and its parent) is enabled
  24558. */
  24559. isEnabled(checkAncestors?: boolean): boolean;
  24560. /** @hidden */
  24561. protected _syncParentEnabledState(): void;
  24562. /**
  24563. * Set the enabled state of this node
  24564. * @param value defines the new enabled state
  24565. */
  24566. setEnabled(value: boolean): void;
  24567. /**
  24568. * Is this node a descendant of the given node?
  24569. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  24570. * @param ancestor defines the parent node to inspect
  24571. * @returns a boolean indicating if this node is a descendant of the given node
  24572. */
  24573. isDescendantOf(ancestor: Node): boolean;
  24574. /** @hidden */ getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  24575. /**
  24576. * Will return all nodes that have this node as ascendant
  24577. * @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
  24578. * @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
  24579. * @return all children nodes of all types
  24580. */
  24581. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  24582. /**
  24583. * Get all child-meshes of this node
  24584. * @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)
  24585. * @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
  24586. * @returns an array of AbstractMesh
  24587. */
  24588. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  24589. /**
  24590. * Get all direct children of this node
  24591. * @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
  24592. * @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)
  24593. * @returns an array of Node
  24594. */
  24595. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  24596. /** @hidden */ setReady(state: boolean): void;
  24597. /**
  24598. * Get an animation by name
  24599. * @param name defines the name of the animation to look for
  24600. * @returns null if not found else the requested animation
  24601. */
  24602. getAnimationByName(name: string): Nullable<Animation>;
  24603. /**
  24604. * Creates an animation range for this node
  24605. * @param name defines the name of the range
  24606. * @param from defines the starting key
  24607. * @param to defines the end key
  24608. */
  24609. createAnimationRange(name: string, from: number, to: number): void;
  24610. /**
  24611. * Delete a specific animation range
  24612. * @param name defines the name of the range to delete
  24613. * @param deleteFrames defines if animation frames from the range must be deleted as well
  24614. */
  24615. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  24616. /**
  24617. * Get an animation range by name
  24618. * @param name defines the name of the animation range to look for
  24619. * @returns null if not found else the requested animation range
  24620. */
  24621. getAnimationRange(name: string): Nullable<AnimationRange>;
  24622. /**
  24623. * Gets the list of all animation ranges defined on this node
  24624. * @returns an array
  24625. */
  24626. getAnimationRanges(): Nullable<AnimationRange>[];
  24627. /**
  24628. * Will start the animation sequence
  24629. * @param name defines the range frames for animation sequence
  24630. * @param loop defines if the animation should loop (false by default)
  24631. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  24632. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  24633. * @returns the object created for this animation. If range does not exist, it will return null
  24634. */
  24635. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  24636. /**
  24637. * Serialize animation ranges into a JSON compatible object
  24638. * @returns serialization object
  24639. */
  24640. serializeAnimationRanges(): any;
  24641. /**
  24642. * Computes the world matrix of the node
  24643. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  24644. * @returns the world matrix
  24645. */
  24646. computeWorldMatrix(force?: boolean): Matrix;
  24647. /**
  24648. * Releases resources associated with this node.
  24649. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24650. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24651. */
  24652. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24653. /**
  24654. * Parse animation range data from a serialization object and store them into a given node
  24655. * @param node defines where to store the animation ranges
  24656. * @param parsedNode defines the serialization object to read data from
  24657. * @param scene defines the hosting scene
  24658. */
  24659. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  24660. }
  24661. }
  24662. declare module BABYLON {
  24663. /**
  24664. * Class used to store any kind of animation
  24665. */
  24666. export class Animation {
  24667. /**Name of the animation */
  24668. name: string;
  24669. /**Property to animate */
  24670. targetProperty: string;
  24671. /**The frames per second of the animation */
  24672. framePerSecond: number;
  24673. /**The data type of the animation */
  24674. dataType: number;
  24675. /**The loop mode of the animation */
  24676. loopMode?: number | undefined;
  24677. /**Specifies if blending should be enabled */
  24678. enableBlending?: boolean | undefined;
  24679. /**
  24680. * Use matrix interpolation instead of using direct key value when animating matrices
  24681. */
  24682. static AllowMatricesInterpolation: boolean;
  24683. /**
  24684. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  24685. */
  24686. static AllowMatrixDecomposeForInterpolation: boolean;
  24687. /**
  24688. * Stores the key frames of the animation
  24689. */
  24690. private _keys;
  24691. /**
  24692. * Stores the easing function of the animation
  24693. */
  24694. private _easingFunction;
  24695. /**
  24696. * @hidden Internal use only
  24697. */ runtimeAnimations: RuntimeAnimation[];
  24698. /**
  24699. * The set of event that will be linked to this animation
  24700. */
  24701. private _events;
  24702. /**
  24703. * Stores an array of target property paths
  24704. */
  24705. targetPropertyPath: string[];
  24706. /**
  24707. * Stores the blending speed of the animation
  24708. */
  24709. blendingSpeed: number;
  24710. /**
  24711. * Stores the animation ranges for the animation
  24712. */
  24713. private _ranges;
  24714. /**
  24715. * @hidden Internal use
  24716. */ private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  24717. /**
  24718. * Sets up an animation
  24719. * @param property The property to animate
  24720. * @param animationType The animation type to apply
  24721. * @param framePerSecond The frames per second of the animation
  24722. * @param easingFunction The easing function used in the animation
  24723. * @returns The created animation
  24724. */
  24725. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  24726. /**
  24727. * Create and start an animation on a node
  24728. * @param name defines the name of the global animation that will be run on all nodes
  24729. * @param node defines the root node where the animation will take place
  24730. * @param targetProperty defines property to animate
  24731. * @param framePerSecond defines the number of frame per second yo use
  24732. * @param totalFrame defines the number of frames in total
  24733. * @param from defines the initial value
  24734. * @param to defines the final value
  24735. * @param loopMode defines which loop mode you want to use (off by default)
  24736. * @param easingFunction defines the easing function to use (linear by default)
  24737. * @param onAnimationEnd defines the callback to call when animation end
  24738. * @returns the animatable created for this animation
  24739. */
  24740. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  24741. /**
  24742. * Create and start an animation on a node and its descendants
  24743. * @param name defines the name of the global animation that will be run on all nodes
  24744. * @param node defines the root node where the animation will take place
  24745. * @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
  24746. * @param targetProperty defines property to animate
  24747. * @param framePerSecond defines the number of frame per second to use
  24748. * @param totalFrame defines the number of frames in total
  24749. * @param from defines the initial value
  24750. * @param to defines the final value
  24751. * @param loopMode defines which loop mode you want to use (off by default)
  24752. * @param easingFunction defines the easing function to use (linear by default)
  24753. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  24754. * @returns the list of animatables created for all nodes
  24755. * @example https://www.babylonjs-playground.com/#MH0VLI
  24756. */
  24757. 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[]>;
  24758. /**
  24759. * Creates a new animation, merges it with the existing animations and starts it
  24760. * @param name Name of the animation
  24761. * @param node Node which contains the scene that begins the animations
  24762. * @param targetProperty Specifies which property to animate
  24763. * @param framePerSecond The frames per second of the animation
  24764. * @param totalFrame The total number of frames
  24765. * @param from The frame at the beginning of the animation
  24766. * @param to The frame at the end of the animation
  24767. * @param loopMode Specifies the loop mode of the animation
  24768. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  24769. * @param onAnimationEnd Callback to run once the animation is complete
  24770. * @returns Nullable animation
  24771. */
  24772. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  24773. /**
  24774. * Transition property of an host to the target Value
  24775. * @param property The property to transition
  24776. * @param targetValue The target Value of the property
  24777. * @param host The object where the property to animate belongs
  24778. * @param scene Scene used to run the animation
  24779. * @param frameRate Framerate (in frame/s) to use
  24780. * @param transition The transition type we want to use
  24781. * @param duration The duration of the animation, in milliseconds
  24782. * @param onAnimationEnd Callback trigger at the end of the animation
  24783. * @returns Nullable animation
  24784. */
  24785. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  24786. /**
  24787. * Return the array of runtime animations currently using this animation
  24788. */
  24789. readonly runtimeAnimations: RuntimeAnimation[];
  24790. /**
  24791. * Specifies if any of the runtime animations are currently running
  24792. */
  24793. readonly hasRunningRuntimeAnimations: boolean;
  24794. /**
  24795. * Initializes the animation
  24796. * @param name Name of the animation
  24797. * @param targetProperty Property to animate
  24798. * @param framePerSecond The frames per second of the animation
  24799. * @param dataType The data type of the animation
  24800. * @param loopMode The loop mode of the animation
  24801. * @param enableBlending Specifies if blending should be enabled
  24802. */
  24803. constructor(
  24804. /**Name of the animation */
  24805. name: string,
  24806. /**Property to animate */
  24807. targetProperty: string,
  24808. /**The frames per second of the animation */
  24809. framePerSecond: number,
  24810. /**The data type of the animation */
  24811. dataType: number,
  24812. /**The loop mode of the animation */
  24813. loopMode?: number | undefined,
  24814. /**Specifies if blending should be enabled */
  24815. enableBlending?: boolean | undefined);
  24816. /**
  24817. * Converts the animation to a string
  24818. * @param fullDetails support for multiple levels of logging within scene loading
  24819. * @returns String form of the animation
  24820. */
  24821. toString(fullDetails?: boolean): string;
  24822. /**
  24823. * Add an event to this animation
  24824. * @param event Event to add
  24825. */
  24826. addEvent(event: AnimationEvent): void;
  24827. /**
  24828. * Remove all events found at the given frame
  24829. * @param frame The frame to remove events from
  24830. */
  24831. removeEvents(frame: number): void;
  24832. /**
  24833. * Retrieves all the events from the animation
  24834. * @returns Events from the animation
  24835. */
  24836. getEvents(): AnimationEvent[];
  24837. /**
  24838. * Creates an animation range
  24839. * @param name Name of the animation range
  24840. * @param from Starting frame of the animation range
  24841. * @param to Ending frame of the animation
  24842. */
  24843. createRange(name: string, from: number, to: number): void;
  24844. /**
  24845. * Deletes an animation range by name
  24846. * @param name Name of the animation range to delete
  24847. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  24848. */
  24849. deleteRange(name: string, deleteFrames?: boolean): void;
  24850. /**
  24851. * Gets the animation range by name, or null if not defined
  24852. * @param name Name of the animation range
  24853. * @returns Nullable animation range
  24854. */
  24855. getRange(name: string): Nullable<AnimationRange>;
  24856. /**
  24857. * Gets the key frames from the animation
  24858. * @returns The key frames of the animation
  24859. */
  24860. getKeys(): Array<IAnimationKey>;
  24861. /**
  24862. * Gets the highest frame rate of the animation
  24863. * @returns Highest frame rate of the animation
  24864. */
  24865. getHighestFrame(): number;
  24866. /**
  24867. * Gets the easing function of the animation
  24868. * @returns Easing function of the animation
  24869. */
  24870. getEasingFunction(): IEasingFunction;
  24871. /**
  24872. * Sets the easing function of the animation
  24873. * @param easingFunction A custom mathematical formula for animation
  24874. */
  24875. setEasingFunction(easingFunction: EasingFunction): void;
  24876. /**
  24877. * Interpolates a scalar linearly
  24878. * @param startValue Start value of the animation curve
  24879. * @param endValue End value of the animation curve
  24880. * @param gradient Scalar amount to interpolate
  24881. * @returns Interpolated scalar value
  24882. */
  24883. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  24884. /**
  24885. * Interpolates a scalar cubically
  24886. * @param startValue Start value of the animation curve
  24887. * @param outTangent End tangent of the animation
  24888. * @param endValue End value of the animation curve
  24889. * @param inTangent Start tangent of the animation curve
  24890. * @param gradient Scalar amount to interpolate
  24891. * @returns Interpolated scalar value
  24892. */
  24893. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  24894. /**
  24895. * Interpolates a quaternion using a spherical linear interpolation
  24896. * @param startValue Start value of the animation curve
  24897. * @param endValue End value of the animation curve
  24898. * @param gradient Scalar amount to interpolate
  24899. * @returns Interpolated quaternion value
  24900. */
  24901. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  24902. /**
  24903. * Interpolates a quaternion cubically
  24904. * @param startValue Start value of the animation curve
  24905. * @param outTangent End tangent of the animation curve
  24906. * @param endValue End value of the animation curve
  24907. * @param inTangent Start tangent of the animation curve
  24908. * @param gradient Scalar amount to interpolate
  24909. * @returns Interpolated quaternion value
  24910. */
  24911. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  24912. /**
  24913. * Interpolates a Vector3 linearl
  24914. * @param startValue Start value of the animation curve
  24915. * @param endValue End value of the animation curve
  24916. * @param gradient Scalar amount to interpolate
  24917. * @returns Interpolated scalar value
  24918. */
  24919. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  24920. /**
  24921. * Interpolates a Vector3 cubically
  24922. * @param startValue Start value of the animation curve
  24923. * @param outTangent End tangent of the animation
  24924. * @param endValue End value of the animation curve
  24925. * @param inTangent Start tangent of the animation curve
  24926. * @param gradient Scalar amount to interpolate
  24927. * @returns InterpolatedVector3 value
  24928. */
  24929. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  24930. /**
  24931. * Interpolates a Vector2 linearly
  24932. * @param startValue Start value of the animation curve
  24933. * @param endValue End value of the animation curve
  24934. * @param gradient Scalar amount to interpolate
  24935. * @returns Interpolated Vector2 value
  24936. */
  24937. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  24938. /**
  24939. * Interpolates a Vector2 cubically
  24940. * @param startValue Start value of the animation curve
  24941. * @param outTangent End tangent of the animation
  24942. * @param endValue End value of the animation curve
  24943. * @param inTangent Start tangent of the animation curve
  24944. * @param gradient Scalar amount to interpolate
  24945. * @returns Interpolated Vector2 value
  24946. */
  24947. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  24948. /**
  24949. * Interpolates a size linearly
  24950. * @param startValue Start value of the animation curve
  24951. * @param endValue End value of the animation curve
  24952. * @param gradient Scalar amount to interpolate
  24953. * @returns Interpolated Size value
  24954. */
  24955. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  24956. /**
  24957. * Interpolates a Color3 linearly
  24958. * @param startValue Start value of the animation curve
  24959. * @param endValue End value of the animation curve
  24960. * @param gradient Scalar amount to interpolate
  24961. * @returns Interpolated Color3 value
  24962. */
  24963. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  24964. /**
  24965. * @hidden Internal use only
  24966. */ getKeyValue(value: any): any;
  24967. /**
  24968. * @hidden Internal use only
  24969. */ interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  24970. /**
  24971. * Defines the function to use to interpolate matrices
  24972. * @param startValue defines the start matrix
  24973. * @param endValue defines the end matrix
  24974. * @param gradient defines the gradient between both matrices
  24975. * @param result defines an optional target matrix where to store the interpolation
  24976. * @returns the interpolated matrix
  24977. */
  24978. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  24979. /**
  24980. * Makes a copy of the animation
  24981. * @returns Cloned animation
  24982. */
  24983. clone(): Animation;
  24984. /**
  24985. * Sets the key frames of the animation
  24986. * @param values The animation key frames to set
  24987. */
  24988. setKeys(values: Array<IAnimationKey>): void;
  24989. /**
  24990. * Serializes the animation to an object
  24991. * @returns Serialized object
  24992. */
  24993. serialize(): any;
  24994. /**
  24995. * Float animation type
  24996. */
  24997. private static _ANIMATIONTYPE_FLOAT;
  24998. /**
  24999. * Vector3 animation type
  25000. */
  25001. private static _ANIMATIONTYPE_VECTOR3;
  25002. /**
  25003. * Quaternion animation type
  25004. */
  25005. private static _ANIMATIONTYPE_QUATERNION;
  25006. /**
  25007. * Matrix animation type
  25008. */
  25009. private static _ANIMATIONTYPE_MATRIX;
  25010. /**
  25011. * Color3 animation type
  25012. */
  25013. private static _ANIMATIONTYPE_COLOR3;
  25014. /**
  25015. * Vector2 animation type
  25016. */
  25017. private static _ANIMATIONTYPE_VECTOR2;
  25018. /**
  25019. * Size animation type
  25020. */
  25021. private static _ANIMATIONTYPE_SIZE;
  25022. /**
  25023. * Relative Loop Mode
  25024. */
  25025. private static _ANIMATIONLOOPMODE_RELATIVE;
  25026. /**
  25027. * Cycle Loop Mode
  25028. */
  25029. private static _ANIMATIONLOOPMODE_CYCLE;
  25030. /**
  25031. * Constant Loop Mode
  25032. */
  25033. private static _ANIMATIONLOOPMODE_CONSTANT;
  25034. /**
  25035. * Get the float animation type
  25036. */
  25037. static readonly ANIMATIONTYPE_FLOAT: number;
  25038. /**
  25039. * Get the Vector3 animation type
  25040. */
  25041. static readonly ANIMATIONTYPE_VECTOR3: number;
  25042. /**
  25043. * Get the Vector2 animation type
  25044. */
  25045. static readonly ANIMATIONTYPE_VECTOR2: number;
  25046. /**
  25047. * Get the Size animation type
  25048. */
  25049. static readonly ANIMATIONTYPE_SIZE: number;
  25050. /**
  25051. * Get the Quaternion animation type
  25052. */
  25053. static readonly ANIMATIONTYPE_QUATERNION: number;
  25054. /**
  25055. * Get the Matrix animation type
  25056. */
  25057. static readonly ANIMATIONTYPE_MATRIX: number;
  25058. /**
  25059. * Get the Color3 animation type
  25060. */
  25061. static readonly ANIMATIONTYPE_COLOR3: number;
  25062. /**
  25063. * Get the Relative Loop Mode
  25064. */
  25065. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25066. /**
  25067. * Get the Cycle Loop Mode
  25068. */
  25069. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25070. /**
  25071. * Get the Constant Loop Mode
  25072. */
  25073. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25074. /** @hidden */ private static _UniversalLerp(left: any, right: any, amount: number): any;
  25075. /**
  25076. * Parses an animation object and creates an animation
  25077. * @param parsedAnimation Parsed animation object
  25078. * @returns Animation object
  25079. */
  25080. static Parse(parsedAnimation: any): Animation;
  25081. /**
  25082. * Appends the serialized animations from the source animations
  25083. * @param source Source containing the animations
  25084. * @param destination Target to store the animations
  25085. */
  25086. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25087. }
  25088. }
  25089. declare module BABYLON {
  25090. /**
  25091. * Base class of all the textures in babylon.
  25092. * It groups all the common properties the materials, post process, lights... might need
  25093. * in order to make a correct use of the texture.
  25094. */
  25095. export class BaseTexture implements IAnimatable {
  25096. /**
  25097. * Default anisotropic filtering level for the application.
  25098. * It is set to 4 as a good tradeoff between perf and quality.
  25099. */
  25100. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25101. /**
  25102. * Gets or sets the unique id of the texture
  25103. */
  25104. uniqueId: number;
  25105. /**
  25106. * Define the name of the texture.
  25107. */
  25108. name: string;
  25109. /**
  25110. * Gets or sets an object used to store user defined information.
  25111. */
  25112. metadata: any;
  25113. /**
  25114. * For internal use only. Please do not use.
  25115. */
  25116. reservedDataStore: any;
  25117. private _hasAlpha;
  25118. /**
  25119. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25120. */
  25121. hasAlpha: boolean;
  25122. /**
  25123. * Defines if the alpha value should be determined via the rgb values.
  25124. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25125. */
  25126. getAlphaFromRGB: boolean;
  25127. /**
  25128. * Intensity or strength of the texture.
  25129. * It is commonly used by materials to fine tune the intensity of the texture
  25130. */
  25131. level: number;
  25132. /**
  25133. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25134. * This is part of the texture as textures usually maps to one uv set.
  25135. */
  25136. coordinatesIndex: number;
  25137. private _coordinatesMode;
  25138. /**
  25139. * How a texture is mapped.
  25140. *
  25141. * | Value | Type | Description |
  25142. * | ----- | ----------------------------------- | ----------- |
  25143. * | 0 | EXPLICIT_MODE | |
  25144. * | 1 | SPHERICAL_MODE | |
  25145. * | 2 | PLANAR_MODE | |
  25146. * | 3 | CUBIC_MODE | |
  25147. * | 4 | PROJECTION_MODE | |
  25148. * | 5 | SKYBOX_MODE | |
  25149. * | 6 | INVCUBIC_MODE | |
  25150. * | 7 | EQUIRECTANGULAR_MODE | |
  25151. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25152. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25153. */
  25154. coordinatesMode: number;
  25155. /**
  25156. * | Value | Type | Description |
  25157. * | ----- | ------------------ | ----------- |
  25158. * | 0 | CLAMP_ADDRESSMODE | |
  25159. * | 1 | WRAP_ADDRESSMODE | |
  25160. * | 2 | MIRROR_ADDRESSMODE | |
  25161. */
  25162. wrapU: number;
  25163. /**
  25164. * | Value | Type | Description |
  25165. * | ----- | ------------------ | ----------- |
  25166. * | 0 | CLAMP_ADDRESSMODE | |
  25167. * | 1 | WRAP_ADDRESSMODE | |
  25168. * | 2 | MIRROR_ADDRESSMODE | |
  25169. */
  25170. wrapV: number;
  25171. /**
  25172. * | Value | Type | Description |
  25173. * | ----- | ------------------ | ----------- |
  25174. * | 0 | CLAMP_ADDRESSMODE | |
  25175. * | 1 | WRAP_ADDRESSMODE | |
  25176. * | 2 | MIRROR_ADDRESSMODE | |
  25177. */
  25178. wrapR: number;
  25179. /**
  25180. * With compliant hardware and browser (supporting anisotropic filtering)
  25181. * this defines the level of anisotropic filtering in the texture.
  25182. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25183. */
  25184. anisotropicFilteringLevel: number;
  25185. /**
  25186. * Define if the texture is a cube texture or if false a 2d texture.
  25187. */
  25188. isCube: boolean;
  25189. /**
  25190. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25191. */
  25192. is3D: boolean;
  25193. /**
  25194. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25195. * HDR texture are usually stored in linear space.
  25196. * This only impacts the PBR and Background materials
  25197. */
  25198. gammaSpace: boolean;
  25199. /**
  25200. * Gets whether or not the texture contains RGBD data.
  25201. */
  25202. readonly isRGBD: boolean;
  25203. /**
  25204. * Is Z inverted in the texture (useful in a cube texture).
  25205. */
  25206. invertZ: boolean;
  25207. /**
  25208. * Are mip maps generated for this texture or not.
  25209. */
  25210. readonly noMipmap: boolean;
  25211. /**
  25212. * @hidden
  25213. */
  25214. lodLevelInAlpha: boolean;
  25215. /**
  25216. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25217. */
  25218. lodGenerationOffset: number;
  25219. /**
  25220. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25221. */
  25222. lodGenerationScale: number;
  25223. /**
  25224. * Define if the texture is a render target.
  25225. */
  25226. isRenderTarget: boolean;
  25227. /**
  25228. * Define the unique id of the texture in the scene.
  25229. */
  25230. readonly uid: string;
  25231. /**
  25232. * Return a string representation of the texture.
  25233. * @returns the texture as a string
  25234. */
  25235. toString(): string;
  25236. /**
  25237. * Get the class name of the texture.
  25238. * @returns "BaseTexture"
  25239. */
  25240. getClassName(): string;
  25241. /**
  25242. * Define the list of animation attached to the texture.
  25243. */
  25244. animations: Animation[];
  25245. /**
  25246. * An event triggered when the texture is disposed.
  25247. */
  25248. onDisposeObservable: Observable<BaseTexture>;
  25249. private _onDisposeObserver;
  25250. /**
  25251. * Callback triggered when the texture has been disposed.
  25252. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25253. */
  25254. onDispose: () => void;
  25255. /**
  25256. * Define the current state of the loading sequence when in delayed load mode.
  25257. */
  25258. delayLoadState: number;
  25259. private _scene;
  25260. /** @hidden */ texture: Nullable<InternalTexture>;
  25261. private _uid;
  25262. /**
  25263. * Define if the texture is preventinga material to render or not.
  25264. * If not and the texture is not ready, the engine will use a default black texture instead.
  25265. */
  25266. readonly isBlocking: boolean;
  25267. /**
  25268. * Instantiates a new BaseTexture.
  25269. * Base class of all the textures in babylon.
  25270. * It groups all the common properties the materials, post process, lights... might need
  25271. * in order to make a correct use of the texture.
  25272. * @param scene Define the scene the texture blongs to
  25273. */
  25274. constructor(scene: Nullable<Scene>);
  25275. /**
  25276. * Get the scene the texture belongs to.
  25277. * @returns the scene or null if undefined
  25278. */
  25279. getScene(): Nullable<Scene>;
  25280. /**
  25281. * Get the texture transform matrix used to offset tile the texture for istance.
  25282. * @returns the transformation matrix
  25283. */
  25284. getTextureMatrix(): Matrix;
  25285. /**
  25286. * Get the texture reflection matrix used to rotate/transform the reflection.
  25287. * @returns the reflection matrix
  25288. */
  25289. getReflectionTextureMatrix(): Matrix;
  25290. /**
  25291. * Get the underlying lower level texture from Babylon.
  25292. * @returns the insternal texture
  25293. */
  25294. getInternalTexture(): Nullable<InternalTexture>;
  25295. /**
  25296. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25297. * @returns true if ready or not blocking
  25298. */
  25299. isReadyOrNotBlocking(): boolean;
  25300. /**
  25301. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25302. * @returns true if fully ready
  25303. */
  25304. isReady(): boolean;
  25305. private _cachedSize;
  25306. /**
  25307. * Get the size of the texture.
  25308. * @returns the texture size.
  25309. */
  25310. getSize(): ISize;
  25311. /**
  25312. * Get the base size of the texture.
  25313. * It can be different from the size if the texture has been resized for POT for instance
  25314. * @returns the base size
  25315. */
  25316. getBaseSize(): ISize;
  25317. /**
  25318. * Update the sampling mode of the texture.
  25319. * Default is Trilinear mode.
  25320. *
  25321. * | Value | Type | Description |
  25322. * | ----- | ------------------ | ----------- |
  25323. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25324. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25325. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25326. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25327. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25328. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25329. * | 7 | NEAREST_LINEAR | |
  25330. * | 8 | NEAREST_NEAREST | |
  25331. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25332. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25333. * | 11 | LINEAR_LINEAR | |
  25334. * | 12 | LINEAR_NEAREST | |
  25335. *
  25336. * > _mag_: magnification filter (close to the viewer)
  25337. * > _min_: minification filter (far from the viewer)
  25338. * > _mip_: filter used between mip map levels
  25339. *@param samplingMode Define the new sampling mode of the texture
  25340. */
  25341. updateSamplingMode(samplingMode: number): void;
  25342. /**
  25343. * Scales the texture if is `canRescale()`
  25344. * @param ratio the resize factor we want to use to rescale
  25345. */
  25346. scale(ratio: number): void;
  25347. /**
  25348. * Get if the texture can rescale.
  25349. */
  25350. readonly canRescale: boolean;
  25351. /** @hidden */ getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  25352. /** @hidden */ rebuild(): void;
  25353. /**
  25354. * Triggers the load sequence in delayed load mode.
  25355. */
  25356. delayLoad(): void;
  25357. /**
  25358. * Clones the texture.
  25359. * @returns the cloned texture
  25360. */
  25361. clone(): Nullable<BaseTexture>;
  25362. /**
  25363. * Get the texture underlying type (INT, FLOAT...)
  25364. */
  25365. readonly textureType: number;
  25366. /**
  25367. * Get the texture underlying format (RGB, RGBA...)
  25368. */
  25369. readonly textureFormat: number;
  25370. /**
  25371. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25372. * This will returns an RGBA array buffer containing either in values (0-255) or
  25373. * float values (0-1) depending of the underlying buffer type.
  25374. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25375. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25376. * @param buffer defines a user defined buffer to fill with data (can be null)
  25377. * @returns The Array buffer containing the pixels data.
  25378. */
  25379. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25380. /**
  25381. * Release and destroy the underlying lower level texture aka internalTexture.
  25382. */
  25383. releaseInternalTexture(): void;
  25384. /**
  25385. * Get the polynomial representation of the texture data.
  25386. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25387. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25388. */
  25389. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25390. /** @hidden */ protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  25391. /** @hidden */ protected readonly _lodTextureMid: Nullable<BaseTexture>;
  25392. /** @hidden */ protected readonly _lodTextureLow: Nullable<BaseTexture>;
  25393. /**
  25394. * Dispose the texture and release its associated resources.
  25395. */
  25396. dispose(): void;
  25397. /**
  25398. * Serialize the texture into a JSON representation that can be parsed later on.
  25399. * @returns the JSON representation of the texture
  25400. */
  25401. serialize(): any;
  25402. /**
  25403. * Helper function to be called back once a list of texture contains only ready textures.
  25404. * @param textures Define the list of textures to wait for
  25405. * @param callback Define the callback triggered once the entire list will be ready
  25406. */
  25407. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25408. }
  25409. }
  25410. declare module BABYLON {
  25411. /**
  25412. * Uniform buffer objects.
  25413. *
  25414. * Handles blocks of uniform on the GPU.
  25415. *
  25416. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25417. *
  25418. * For more information, please refer to :
  25419. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25420. */
  25421. export class UniformBuffer {
  25422. private _engine;
  25423. private _buffer;
  25424. private _data;
  25425. private _bufferData;
  25426. private _dynamic?;
  25427. private _uniformLocations;
  25428. private _uniformSizes;
  25429. private _uniformLocationPointer;
  25430. private _needSync;
  25431. private _noUBO;
  25432. private _currentEffect;
  25433. private static _MAX_UNIFORM_SIZE;
  25434. private static _tempBuffer;
  25435. /**
  25436. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25437. * This is dynamic to allow compat with webgl 1 and 2.
  25438. * You will need to pass the name of the uniform as well as the value.
  25439. */
  25440. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25441. /**
  25442. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25443. * This is dynamic to allow compat with webgl 1 and 2.
  25444. * You will need to pass the name of the uniform as well as the value.
  25445. */
  25446. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25447. /**
  25448. * Lambda to Update a single float in a uniform buffer.
  25449. * This is dynamic to allow compat with webgl 1 and 2.
  25450. * You will need to pass the name of the uniform as well as the value.
  25451. */
  25452. updateFloat: (name: string, x: number) => void;
  25453. /**
  25454. * Lambda to Update a vec2 of float in a uniform buffer.
  25455. * This is dynamic to allow compat with webgl 1 and 2.
  25456. * You will need to pass the name of the uniform as well as the value.
  25457. */
  25458. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25459. /**
  25460. * Lambda to Update a vec3 of float in a uniform buffer.
  25461. * This is dynamic to allow compat with webgl 1 and 2.
  25462. * You will need to pass the name of the uniform as well as the value.
  25463. */
  25464. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25465. /**
  25466. * Lambda to Update a vec4 of float in a uniform buffer.
  25467. * This is dynamic to allow compat with webgl 1 and 2.
  25468. * You will need to pass the name of the uniform as well as the value.
  25469. */
  25470. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25471. /**
  25472. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25473. * This is dynamic to allow compat with webgl 1 and 2.
  25474. * You will need to pass the name of the uniform as well as the value.
  25475. */
  25476. updateMatrix: (name: string, mat: Matrix) => void;
  25477. /**
  25478. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25479. * This is dynamic to allow compat with webgl 1 and 2.
  25480. * You will need to pass the name of the uniform as well as the value.
  25481. */
  25482. updateVector3: (name: string, vector: Vector3) => void;
  25483. /**
  25484. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25485. * This is dynamic to allow compat with webgl 1 and 2.
  25486. * You will need to pass the name of the uniform as well as the value.
  25487. */
  25488. updateVector4: (name: string, vector: Vector4) => void;
  25489. /**
  25490. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25491. * This is dynamic to allow compat with webgl 1 and 2.
  25492. * You will need to pass the name of the uniform as well as the value.
  25493. */
  25494. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25495. /**
  25496. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25497. * This is dynamic to allow compat with webgl 1 and 2.
  25498. * You will need to pass the name of the uniform as well as the value.
  25499. */
  25500. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25501. /**
  25502. * Instantiates a new Uniform buffer objects.
  25503. *
  25504. * Handles blocks of uniform on the GPU.
  25505. *
  25506. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25507. *
  25508. * For more information, please refer to :
  25509. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25510. * @param engine Define the engine the buffer is associated with
  25511. * @param data Define the data contained in the buffer
  25512. * @param dynamic Define if the buffer is updatable
  25513. */
  25514. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25515. /**
  25516. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25517. * or just falling back on setUniformXXX calls.
  25518. */
  25519. readonly useUbo: boolean;
  25520. /**
  25521. * Indicates if the WebGL underlying uniform buffer is in sync
  25522. * with the javascript cache data.
  25523. */
  25524. readonly isSync: boolean;
  25525. /**
  25526. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25527. * Also, a dynamic UniformBuffer will disable cache verification and always
  25528. * update the underlying WebGL uniform buffer to the GPU.
  25529. * @returns if Dynamic, otherwise false
  25530. */
  25531. isDynamic(): boolean;
  25532. /**
  25533. * The data cache on JS side.
  25534. * @returns the underlying data as a float array
  25535. */
  25536. getData(): Float32Array;
  25537. /**
  25538. * The underlying WebGL Uniform buffer.
  25539. * @returns the webgl buffer
  25540. */
  25541. getBuffer(): Nullable<WebGLBuffer>;
  25542. /**
  25543. * std140 layout specifies how to align data within an UBO structure.
  25544. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  25545. * for specs.
  25546. */
  25547. private _fillAlignment;
  25548. /**
  25549. * Adds an uniform in the buffer.
  25550. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  25551. * for the layout to be correct !
  25552. * @param name Name of the uniform, as used in the uniform block in the shader.
  25553. * @param size Data size, or data directly.
  25554. */
  25555. addUniform(name: string, size: number | number[]): void;
  25556. /**
  25557. * Adds a Matrix 4x4 to the uniform buffer.
  25558. * @param name Name of the uniform, as used in the uniform block in the shader.
  25559. * @param mat A 4x4 matrix.
  25560. */
  25561. addMatrix(name: string, mat: Matrix): void;
  25562. /**
  25563. * Adds a vec2 to the uniform buffer.
  25564. * @param name Name of the uniform, as used in the uniform block in the shader.
  25565. * @param x Define the x component value of the vec2
  25566. * @param y Define the y component value of the vec2
  25567. */
  25568. addFloat2(name: string, x: number, y: number): void;
  25569. /**
  25570. * Adds a vec3 to the uniform buffer.
  25571. * @param name Name of the uniform, as used in the uniform block in the shader.
  25572. * @param x Define the x component value of the vec3
  25573. * @param y Define the y component value of the vec3
  25574. * @param z Define the z component value of the vec3
  25575. */
  25576. addFloat3(name: string, x: number, y: number, z: number): void;
  25577. /**
  25578. * Adds a vec3 to the uniform buffer.
  25579. * @param name Name of the uniform, as used in the uniform block in the shader.
  25580. * @param color Define the vec3 from a Color
  25581. */
  25582. addColor3(name: string, color: Color3): void;
  25583. /**
  25584. * Adds a vec4 to the uniform buffer.
  25585. * @param name Name of the uniform, as used in the uniform block in the shader.
  25586. * @param color Define the rgb components from a Color
  25587. * @param alpha Define the a component of the vec4
  25588. */
  25589. addColor4(name: string, color: Color3, alpha: number): void;
  25590. /**
  25591. * Adds a vec3 to the uniform buffer.
  25592. * @param name Name of the uniform, as used in the uniform block in the shader.
  25593. * @param vector Define the vec3 components from a Vector
  25594. */
  25595. addVector3(name: string, vector: Vector3): void;
  25596. /**
  25597. * Adds a Matrix 3x3 to the uniform buffer.
  25598. * @param name Name of the uniform, as used in the uniform block in the shader.
  25599. */
  25600. addMatrix3x3(name: string): void;
  25601. /**
  25602. * Adds a Matrix 2x2 to the uniform buffer.
  25603. * @param name Name of the uniform, as used in the uniform block in the shader.
  25604. */
  25605. addMatrix2x2(name: string): void;
  25606. /**
  25607. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  25608. */
  25609. create(): void;
  25610. /** @hidden */ rebuild(): void;
  25611. /**
  25612. * Updates the WebGL Uniform Buffer on the GPU.
  25613. * If the `dynamic` flag is set to true, no cache comparison is done.
  25614. * Otherwise, the buffer will be updated only if the cache differs.
  25615. */
  25616. update(): void;
  25617. /**
  25618. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  25619. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  25620. * @param data Define the flattened data
  25621. * @param size Define the size of the data.
  25622. */
  25623. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  25624. private _updateMatrix3x3ForUniform;
  25625. private _updateMatrix3x3ForEffect;
  25626. private _updateMatrix2x2ForEffect;
  25627. private _updateMatrix2x2ForUniform;
  25628. private _updateFloatForEffect;
  25629. private _updateFloatForUniform;
  25630. private _updateFloat2ForEffect;
  25631. private _updateFloat2ForUniform;
  25632. private _updateFloat3ForEffect;
  25633. private _updateFloat3ForUniform;
  25634. private _updateFloat4ForEffect;
  25635. private _updateFloat4ForUniform;
  25636. private _updateMatrixForEffect;
  25637. private _updateMatrixForUniform;
  25638. private _updateVector3ForEffect;
  25639. private _updateVector3ForUniform;
  25640. private _updateVector4ForEffect;
  25641. private _updateVector4ForUniform;
  25642. private _updateColor3ForEffect;
  25643. private _updateColor3ForUniform;
  25644. private _updateColor4ForEffect;
  25645. private _updateColor4ForUniform;
  25646. /**
  25647. * Sets a sampler uniform on the effect.
  25648. * @param name Define the name of the sampler.
  25649. * @param texture Define the texture to set in the sampler
  25650. */
  25651. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  25652. /**
  25653. * Directly updates the value of the uniform in the cache AND on the GPU.
  25654. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  25655. * @param data Define the flattened data
  25656. */
  25657. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  25658. /**
  25659. * Binds this uniform buffer to an effect.
  25660. * @param effect Define the effect to bind the buffer to
  25661. * @param name Name of the uniform block in the shader.
  25662. */
  25663. bindToEffect(effect: Effect, name: string): void;
  25664. /**
  25665. * Disposes the uniform buffer.
  25666. */
  25667. dispose(): void;
  25668. }
  25669. }
  25670. declare module BABYLON {
  25671. /**
  25672. * This represents the required contract to create a new type of texture loader.
  25673. */
  25674. export interface IInternalTextureLoader {
  25675. /**
  25676. * Defines wether the loader supports cascade loading the different faces.
  25677. */
  25678. supportCascades: boolean;
  25679. /**
  25680. * This returns if the loader support the current file information.
  25681. * @param extension defines the file extension of the file being loaded
  25682. * @param textureFormatInUse defines the current compressed format in use iun the engine
  25683. * @param fallback defines the fallback internal texture if any
  25684. * @param isBase64 defines whether the texture is encoded as a base64
  25685. * @param isBuffer defines whether the texture data are stored as a buffer
  25686. * @returns true if the loader can load the specified file
  25687. */
  25688. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  25689. /**
  25690. * Transform the url before loading if required.
  25691. * @param rootUrl the url of the texture
  25692. * @param textureFormatInUse defines the current compressed format in use iun the engine
  25693. * @returns the transformed texture
  25694. */
  25695. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  25696. /**
  25697. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  25698. * @param rootUrl the url of the texture
  25699. * @param textureFormatInUse defines the current compressed format in use iun the engine
  25700. * @returns the fallback texture
  25701. */
  25702. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  25703. /**
  25704. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  25705. * @param data contains the texture data
  25706. * @param texture defines the BabylonJS internal texture
  25707. * @param createPolynomials will be true if polynomials have been requested
  25708. * @param onLoad defines the callback to trigger once the texture is ready
  25709. * @param onError defines the callback to trigger in case of error
  25710. */
  25711. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  25712. /**
  25713. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  25714. * @param data contains the texture data
  25715. * @param texture defines the BabylonJS internal texture
  25716. * @param callback defines the method to call once ready to upload
  25717. */
  25718. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  25719. }
  25720. }
  25721. declare module BABYLON {
  25722. /**
  25723. * Creation options of the multi render target texture.
  25724. */
  25725. export interface IMultiRenderTargetOptions {
  25726. /**
  25727. * Define if the texture needs to create mip maps after render.
  25728. */
  25729. generateMipMaps?: boolean;
  25730. /**
  25731. * Define the types of all the draw buffers we want to create
  25732. */
  25733. types?: number[];
  25734. /**
  25735. * Define the sampling modes of all the draw buffers we want to create
  25736. */
  25737. samplingModes?: number[];
  25738. /**
  25739. * Define if a depth buffer is required
  25740. */
  25741. generateDepthBuffer?: boolean;
  25742. /**
  25743. * Define if a stencil buffer is required
  25744. */
  25745. generateStencilBuffer?: boolean;
  25746. /**
  25747. * Define if a depth texture is required instead of a depth buffer
  25748. */
  25749. generateDepthTexture?: boolean;
  25750. /**
  25751. * Define the number of desired draw buffers
  25752. */
  25753. textureCount?: number;
  25754. /**
  25755. * Define if aspect ratio should be adapted to the texture or stay the scene one
  25756. */
  25757. doNotChangeAspectRatio?: boolean;
  25758. /**
  25759. * Define the default type of the buffers we are creating
  25760. */
  25761. defaultType?: number;
  25762. }
  25763. /**
  25764. * A multi render target, like a render target provides the ability to render to a texture.
  25765. * Unlike the render target, it can render to several draw buffers in one draw.
  25766. * This is specially interesting in deferred rendering or for any effects requiring more than
  25767. * just one color from a single pass.
  25768. */
  25769. export class MultiRenderTarget extends RenderTargetTexture {
  25770. private _internalTextures;
  25771. private _textures;
  25772. private _multiRenderTargetOptions;
  25773. /**
  25774. * Get if draw buffers are currently supported by the used hardware and browser.
  25775. */
  25776. readonly isSupported: boolean;
  25777. /**
  25778. * Get the list of textures generated by the multi render target.
  25779. */
  25780. readonly textures: Texture[];
  25781. /**
  25782. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  25783. */
  25784. readonly depthTexture: Texture;
  25785. /**
  25786. * Set the wrapping mode on U of all the textures we are rendering to.
  25787. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25788. */
  25789. wrapU: number;
  25790. /**
  25791. * Set the wrapping mode on V of all the textures we are rendering to.
  25792. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25793. */
  25794. wrapV: number;
  25795. /**
  25796. * Instantiate a new multi render target texture.
  25797. * A multi render target, like a render target provides the ability to render to a texture.
  25798. * Unlike the render target, it can render to several draw buffers in one draw.
  25799. * This is specially interesting in deferred rendering or for any effects requiring more than
  25800. * just one color from a single pass.
  25801. * @param name Define the name of the texture
  25802. * @param size Define the size of the buffers to render to
  25803. * @param count Define the number of target we are rendering into
  25804. * @param scene Define the scene the texture belongs to
  25805. * @param options Define the options used to create the multi render target
  25806. */
  25807. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  25808. /** @hidden */ rebuild(): void;
  25809. private _createInternalTextures;
  25810. private _createTextures;
  25811. /**
  25812. * Define the number of samples used if MSAA is enabled.
  25813. */
  25814. samples: number;
  25815. /**
  25816. * Resize all the textures in the multi render target.
  25817. * Be carrefull as it will recreate all the data in the new texture.
  25818. * @param size Define the new size
  25819. */
  25820. resize(size: any): void;
  25821. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  25822. /**
  25823. * Dispose the render targets and their associated resources
  25824. */
  25825. dispose(): void;
  25826. /**
  25827. * Release all the underlying texture used as draw buffers.
  25828. */
  25829. releaseInternalTextures(): void;
  25830. }
  25831. }
  25832. declare module BABYLON {
  25833. /**
  25834. * Class used to work with sound analyzer using fast fourier transform (FFT)
  25835. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25836. */
  25837. export class Analyser {
  25838. /**
  25839. * Gets or sets the smoothing
  25840. * @ignorenaming
  25841. */
  25842. SMOOTHING: number;
  25843. /**
  25844. * Gets or sets the FFT table size
  25845. * @ignorenaming
  25846. */
  25847. FFT_SIZE: number;
  25848. /**
  25849. * Gets or sets the bar graph amplitude
  25850. * @ignorenaming
  25851. */
  25852. BARGRAPHAMPLITUDE: number;
  25853. /**
  25854. * Gets or sets the position of the debug canvas
  25855. * @ignorenaming
  25856. */
  25857. DEBUGCANVASPOS: {
  25858. x: number;
  25859. y: number;
  25860. };
  25861. /**
  25862. * Gets or sets the debug canvas size
  25863. * @ignorenaming
  25864. */
  25865. DEBUGCANVASSIZE: {
  25866. width: number;
  25867. height: number;
  25868. };
  25869. private _byteFreqs;
  25870. private _byteTime;
  25871. private _floatFreqs;
  25872. private _webAudioAnalyser;
  25873. private _debugCanvas;
  25874. private _debugCanvasContext;
  25875. private _scene;
  25876. private _registerFunc;
  25877. private _audioEngine;
  25878. /**
  25879. * Creates a new analyser
  25880. * @param scene defines hosting scene
  25881. */
  25882. constructor(scene: Scene);
  25883. /**
  25884. * Get the number of data values you will have to play with for the visualization
  25885. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  25886. * @returns a number
  25887. */
  25888. getFrequencyBinCount(): number;
  25889. /**
  25890. * Gets the current frequency data as a byte array
  25891. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  25892. * @returns a Uint8Array
  25893. */
  25894. getByteFrequencyData(): Uint8Array;
  25895. /**
  25896. * Gets the current waveform as a byte array
  25897. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  25898. * @returns a Uint8Array
  25899. */
  25900. getByteTimeDomainData(): Uint8Array;
  25901. /**
  25902. * Gets the current frequency data as a float array
  25903. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  25904. * @returns a Float32Array
  25905. */
  25906. getFloatFrequencyData(): Float32Array;
  25907. /**
  25908. * Renders the debug canvas
  25909. */
  25910. drawDebugCanvas(): void;
  25911. /**
  25912. * Stops rendering the debug canvas and removes it
  25913. */
  25914. stopDebugCanvas(): void;
  25915. /**
  25916. * Connects two audio nodes
  25917. * @param inputAudioNode defines first node to connect
  25918. * @param outputAudioNode defines second node to connect
  25919. */
  25920. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  25921. /**
  25922. * Releases all associated resources
  25923. */
  25924. dispose(): void;
  25925. }
  25926. }
  25927. declare module BABYLON {
  25928. /**
  25929. * This represents an audio engine and it is responsible
  25930. * to play, synchronize and analyse sounds throughout the application.
  25931. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25932. */
  25933. export interface IAudioEngine extends IDisposable {
  25934. /**
  25935. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  25936. */
  25937. readonly canUseWebAudio: boolean;
  25938. /**
  25939. * Gets the current AudioContext if available.
  25940. */
  25941. readonly audioContext: Nullable<AudioContext>;
  25942. /**
  25943. * The master gain node defines the global audio volume of your audio engine.
  25944. */
  25945. readonly masterGain: GainNode;
  25946. /**
  25947. * Gets whether or not mp3 are supported by your browser.
  25948. */
  25949. readonly isMP3supported: boolean;
  25950. /**
  25951. * Gets whether or not ogg are supported by your browser.
  25952. */
  25953. readonly isOGGsupported: boolean;
  25954. /**
  25955. * Defines if Babylon should emit a warning if WebAudio is not supported.
  25956. * @ignoreNaming
  25957. */
  25958. WarnedWebAudioUnsupported: boolean;
  25959. /**
  25960. * Defines if the audio engine relies on a custom unlocked button.
  25961. * In this case, the embedded button will not be displayed.
  25962. */
  25963. useCustomUnlockedButton: boolean;
  25964. /**
  25965. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  25966. */
  25967. readonly unlocked: boolean;
  25968. /**
  25969. * Event raised when audio has been unlocked on the browser.
  25970. */
  25971. onAudioUnlockedObservable: Observable<AudioEngine>;
  25972. /**
  25973. * Event raised when audio has been locked on the browser.
  25974. */
  25975. onAudioLockedObservable: Observable<AudioEngine>;
  25976. /**
  25977. * Flags the audio engine in Locked state.
  25978. * This happens due to new browser policies preventing audio to autoplay.
  25979. */
  25980. lock(): void;
  25981. /**
  25982. * Unlocks the audio engine once a user action has been done on the dom.
  25983. * This is helpful to resume play once browser policies have been satisfied.
  25984. */
  25985. unlock(): void;
  25986. }
  25987. /**
  25988. * This represents the default audio engine used in babylon.
  25989. * It is responsible to play, synchronize and analyse sounds throughout the application.
  25990. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25991. */
  25992. export class AudioEngine implements IAudioEngine {
  25993. private _audioContext;
  25994. private _audioContextInitialized;
  25995. private _muteButton;
  25996. private _hostElement;
  25997. /**
  25998. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  25999. */
  26000. canUseWebAudio: boolean;
  26001. /**
  26002. * The master gain node defines the global audio volume of your audio engine.
  26003. */
  26004. masterGain: GainNode;
  26005. /**
  26006. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26007. * @ignoreNaming
  26008. */
  26009. WarnedWebAudioUnsupported: boolean;
  26010. /**
  26011. * Gets whether or not mp3 are supported by your browser.
  26012. */
  26013. isMP3supported: boolean;
  26014. /**
  26015. * Gets whether or not ogg are supported by your browser.
  26016. */
  26017. isOGGsupported: boolean;
  26018. /**
  26019. * Gets whether audio has been unlocked on the device.
  26020. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26021. * a user interaction has happened.
  26022. */
  26023. unlocked: boolean;
  26024. /**
  26025. * Defines if the audio engine relies on a custom unlocked button.
  26026. * In this case, the embedded button will not be displayed.
  26027. */
  26028. useCustomUnlockedButton: boolean;
  26029. /**
  26030. * Event raised when audio has been unlocked on the browser.
  26031. */
  26032. onAudioUnlockedObservable: Observable<AudioEngine>;
  26033. /**
  26034. * Event raised when audio has been locked on the browser.
  26035. */
  26036. onAudioLockedObservable: Observable<AudioEngine>;
  26037. /**
  26038. * Gets the current AudioContext if available.
  26039. */
  26040. readonly audioContext: Nullable<AudioContext>;
  26041. private _connectedAnalyser;
  26042. /**
  26043. * Instantiates a new audio engine.
  26044. *
  26045. * There should be only one per page as some browsers restrict the number
  26046. * of audio contexts you can create.
  26047. * @param hostElement defines the host element where to display the mute icon if necessary
  26048. */
  26049. constructor(hostElement?: Nullable<HTMLElement>);
  26050. /**
  26051. * Flags the audio engine in Locked state.
  26052. * This happens due to new browser policies preventing audio to autoplay.
  26053. */
  26054. lock(): void;
  26055. /**
  26056. * Unlocks the audio engine once a user action has been done on the dom.
  26057. * This is helpful to resume play once browser policies have been satisfied.
  26058. */
  26059. unlock(): void;
  26060. private _resumeAudioContext;
  26061. private _initializeAudioContext;
  26062. private _tryToRun;
  26063. private _triggerRunningState;
  26064. private _triggerSuspendedState;
  26065. private _displayMuteButton;
  26066. private _moveButtonToTopLeft;
  26067. private _onResize;
  26068. private _hideMuteButton;
  26069. /**
  26070. * Destroy and release the resources associated with the audio ccontext.
  26071. */
  26072. dispose(): void;
  26073. /**
  26074. * Gets the global volume sets on the master gain.
  26075. * @returns the global volume if set or -1 otherwise
  26076. */
  26077. getGlobalVolume(): number;
  26078. /**
  26079. * Sets the global volume of your experience (sets on the master gain).
  26080. * @param newVolume Defines the new global volume of the application
  26081. */
  26082. setGlobalVolume(newVolume: number): void;
  26083. /**
  26084. * Connect the audio engine to an audio analyser allowing some amazing
  26085. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26086. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26087. * @param analyser The analyser to connect to the engine
  26088. */
  26089. connectToAnalyser(analyser: Analyser): void;
  26090. }
  26091. }
  26092. declare module BABYLON {
  26093. /**
  26094. * Interface used to present a loading screen while loading a scene
  26095. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26096. */
  26097. export interface ILoadingScreen {
  26098. /**
  26099. * Function called to display the loading screen
  26100. */
  26101. displayLoadingUI: () => void;
  26102. /**
  26103. * Function called to hide the loading screen
  26104. */
  26105. hideLoadingUI: () => void;
  26106. /**
  26107. * Gets or sets the color to use for the background
  26108. */
  26109. loadingUIBackgroundColor: string;
  26110. /**
  26111. * Gets or sets the text to display while loading
  26112. */
  26113. loadingUIText: string;
  26114. }
  26115. /**
  26116. * Class used for the default loading screen
  26117. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26118. */
  26119. export class DefaultLoadingScreen implements ILoadingScreen {
  26120. private _renderingCanvas;
  26121. private _loadingText;
  26122. private _loadingDivBackgroundColor;
  26123. private _loadingDiv;
  26124. private _loadingTextDiv;
  26125. /**
  26126. * Creates a new default loading screen
  26127. * @param _renderingCanvas defines the canvas used to render the scene
  26128. * @param _loadingText defines the default text to display
  26129. * @param _loadingDivBackgroundColor defines the default background color
  26130. */
  26131. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26132. /**
  26133. * Function called to display the loading screen
  26134. */
  26135. displayLoadingUI(): void;
  26136. /**
  26137. * Function called to hide the loading screen
  26138. */
  26139. hideLoadingUI(): void;
  26140. /**
  26141. * Gets or sets the text to display while loading
  26142. */
  26143. loadingUIText: string;
  26144. /**
  26145. * Gets or sets the color to use for the background
  26146. */
  26147. loadingUIBackgroundColor: string;
  26148. private _resizeLoadingUI;
  26149. }
  26150. }
  26151. declare module BABYLON {
  26152. /**
  26153. * Settings for finer control over video usage
  26154. */
  26155. export interface VideoTextureSettings {
  26156. /**
  26157. * Applies `autoplay` to video, if specified
  26158. */
  26159. autoPlay?: boolean;
  26160. /**
  26161. * Applies `loop` to video, if specified
  26162. */
  26163. loop?: boolean;
  26164. /**
  26165. * Automatically updates internal texture from video at every frame in the render loop
  26166. */
  26167. autoUpdateTexture: boolean;
  26168. /**
  26169. * Image src displayed during the video loading or until the user interacts with the video.
  26170. */
  26171. poster?: string;
  26172. }
  26173. /**
  26174. * If you want to display a video in your scene, this is the special texture for that.
  26175. * This special texture works similar to other textures, with the exception of a few parameters.
  26176. * @see https://doc.babylonjs.com/how_to/video_texture
  26177. */
  26178. export class VideoTexture extends Texture {
  26179. /**
  26180. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26181. */
  26182. readonly autoUpdateTexture: boolean;
  26183. /**
  26184. * The video instance used by the texture internally
  26185. */
  26186. readonly video: HTMLVideoElement;
  26187. private _onUserActionRequestedObservable;
  26188. /**
  26189. * Event triggerd when a dom action is required by the user to play the video.
  26190. * This happens due to recent changes in browser policies preventing video to auto start.
  26191. */
  26192. readonly onUserActionRequestedObservable: Observable<Texture>;
  26193. private _generateMipMaps;
  26194. private _engine;
  26195. private _stillImageCaptured;
  26196. private _displayingPosterTexture;
  26197. private _settings;
  26198. private _createInternalTextureOnEvent;
  26199. /**
  26200. * Creates a video texture.
  26201. * If you want to display a video in your scene, this is the special texture for that.
  26202. * This special texture works similar to other textures, with the exception of a few parameters.
  26203. * @see https://doc.babylonjs.com/how_to/video_texture
  26204. * @param name optional name, will detect from video source, if not defined
  26205. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26206. * @param scene is obviously the current scene.
  26207. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26208. * @param invertY is false by default but can be used to invert video on Y axis
  26209. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26210. * @param settings allows finer control over video usage
  26211. */
  26212. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26213. private _getName;
  26214. private _getVideo;
  26215. private _createInternalTexture;
  26216. private reset;
  26217. /**
  26218. * @hidden Internal method to initiate `update`.
  26219. */ rebuild(): void;
  26220. /**
  26221. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26222. */
  26223. update(): void;
  26224. /**
  26225. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26226. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26227. */
  26228. updateTexture(isVisible: boolean): void;
  26229. protected _updateInternalTexture: () => void;
  26230. /**
  26231. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26232. * @param url New url.
  26233. */
  26234. updateURL(url: string): void;
  26235. /**
  26236. * Dispose the texture and release its associated resources.
  26237. */
  26238. dispose(): void;
  26239. /**
  26240. * Creates a video texture straight from a stream.
  26241. * @param scene Define the scene the texture should be created in
  26242. * @param stream Define the stream the texture should be created from
  26243. * @returns The created video texture as a promise
  26244. */
  26245. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26246. /**
  26247. * Creates a video texture straight from your WebCam video feed.
  26248. * @param scene Define the scene the texture should be created in
  26249. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26250. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26251. * @returns The created video texture as a promise
  26252. */
  26253. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26254. minWidth: number;
  26255. maxWidth: number;
  26256. minHeight: number;
  26257. maxHeight: number;
  26258. deviceId: string;
  26259. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26260. /**
  26261. * Creates a video texture straight from your WebCam video feed.
  26262. * @param scene Define the scene the texture should be created in
  26263. * @param onReady Define a callback to triggered once the texture will be ready
  26264. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26265. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26266. */
  26267. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26268. minWidth: number;
  26269. maxWidth: number;
  26270. minHeight: number;
  26271. maxHeight: number;
  26272. deviceId: string;
  26273. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26274. }
  26275. }
  26276. declare module BABYLON {
  26277. /**
  26278. * Interface for attribute information associated with buffer instanciation
  26279. */
  26280. export class InstancingAttributeInfo {
  26281. /**
  26282. * Index/offset of the attribute in the vertex shader
  26283. */
  26284. index: number;
  26285. /**
  26286. * size of the attribute, 1, 2, 3 or 4
  26287. */
  26288. attributeSize: number;
  26289. /**
  26290. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26291. * default is FLOAT
  26292. */
  26293. attribyteType: number;
  26294. /**
  26295. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26296. */
  26297. normalized: boolean;
  26298. /**
  26299. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26300. */
  26301. offset: number;
  26302. /**
  26303. * Name of the GLSL attribute, for debugging purpose only
  26304. */
  26305. attributeName: string;
  26306. }
  26307. /**
  26308. * Define options used to create a depth texture
  26309. */
  26310. export class DepthTextureCreationOptions {
  26311. /** Specifies whether or not a stencil should be allocated in the texture */
  26312. generateStencil?: boolean;
  26313. /** Specifies whether or not bilinear filtering is enable on the texture */
  26314. bilinearFiltering?: boolean;
  26315. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26316. comparisonFunction?: number;
  26317. /** Specifies if the created texture is a cube texture */
  26318. isCube?: boolean;
  26319. }
  26320. /**
  26321. * Class used to describe the capabilities of the engine relatively to the current browser
  26322. */
  26323. export class EngineCapabilities {
  26324. /** Maximum textures units per fragment shader */
  26325. maxTexturesImageUnits: number;
  26326. /** Maximum texture units per vertex shader */
  26327. maxVertexTextureImageUnits: number;
  26328. /** Maximum textures units in the entire pipeline */
  26329. maxCombinedTexturesImageUnits: number;
  26330. /** Maximum texture size */
  26331. maxTextureSize: number;
  26332. /** Maximum cube texture size */
  26333. maxCubemapTextureSize: number;
  26334. /** Maximum render texture size */
  26335. maxRenderTextureSize: number;
  26336. /** Maximum number of vertex attributes */
  26337. maxVertexAttribs: number;
  26338. /** Maximum number of varyings */
  26339. maxVaryingVectors: number;
  26340. /** Maximum number of uniforms per vertex shader */
  26341. maxVertexUniformVectors: number;
  26342. /** Maximum number of uniforms per fragment shader */
  26343. maxFragmentUniformVectors: number;
  26344. /** Defines if standard derivates (dx/dy) are supported */
  26345. standardDerivatives: boolean;
  26346. /** Defines if s3tc texture compression is supported */
  26347. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26348. /** Defines if pvrtc texture compression is supported */
  26349. pvrtc: any;
  26350. /** Defines if etc1 texture compression is supported */
  26351. etc1: any;
  26352. /** Defines if etc2 texture compression is supported */
  26353. etc2: any;
  26354. /** Defines if astc texture compression is supported */
  26355. astc: any;
  26356. /** Defines if float textures are supported */
  26357. textureFloat: boolean;
  26358. /** Defines if vertex array objects are supported */
  26359. vertexArrayObject: boolean;
  26360. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26361. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26362. /** Gets the maximum level of anisotropy supported */
  26363. maxAnisotropy: number;
  26364. /** Defines if instancing is supported */
  26365. instancedArrays: boolean;
  26366. /** Defines if 32 bits indices are supported */
  26367. uintIndices: boolean;
  26368. /** Defines if high precision shaders are supported */
  26369. highPrecisionShaderSupported: boolean;
  26370. /** Defines if depth reading in the fragment shader is supported */
  26371. fragmentDepthSupported: boolean;
  26372. /** Defines if float texture linear filtering is supported*/
  26373. textureFloatLinearFiltering: boolean;
  26374. /** Defines if rendering to float textures is supported */
  26375. textureFloatRender: boolean;
  26376. /** Defines if half float textures are supported*/
  26377. textureHalfFloat: boolean;
  26378. /** Defines if half float texture linear filtering is supported*/
  26379. textureHalfFloatLinearFiltering: boolean;
  26380. /** Defines if rendering to half float textures is supported */
  26381. textureHalfFloatRender: boolean;
  26382. /** Defines if textureLOD shader command is supported */
  26383. textureLOD: boolean;
  26384. /** Defines if draw buffers extension is supported */
  26385. drawBuffersExtension: boolean;
  26386. /** Defines if depth textures are supported */
  26387. depthTextureExtension: boolean;
  26388. /** Defines if float color buffer are supported */
  26389. colorBufferFloat: boolean;
  26390. /** Gets disjoint timer query extension (null if not supported) */
  26391. timerQuery: EXT_disjoint_timer_query;
  26392. /** Defines if timestamp can be used with timer query */
  26393. canUseTimestampForTimerQuery: boolean;
  26394. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  26395. multiview: any;
  26396. /** Function used to let the system compiles shaders in background */
  26397. parallelShaderCompile: {
  26398. COMPLETION_STATUS_KHR: number;
  26399. };
  26400. }
  26401. /** Interface defining initialization parameters for Engine class */
  26402. export interface EngineOptions extends WebGLContextAttributes {
  26403. /**
  26404. * Defines if the engine should no exceed a specified device ratio
  26405. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26406. */
  26407. limitDeviceRatio?: number;
  26408. /**
  26409. * Defines if webvr should be enabled automatically
  26410. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26411. */
  26412. autoEnableWebVR?: boolean;
  26413. /**
  26414. * Defines if webgl2 should be turned off even if supported
  26415. * @see http://doc.babylonjs.com/features/webgl2
  26416. */
  26417. disableWebGL2Support?: boolean;
  26418. /**
  26419. * Defines if webaudio should be initialized as well
  26420. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26421. */
  26422. audioEngine?: boolean;
  26423. /**
  26424. * Defines if animations should run using a deterministic lock step
  26425. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26426. */
  26427. deterministicLockstep?: boolean;
  26428. /** Defines the maximum steps to use with deterministic lock step mode */
  26429. lockstepMaxSteps?: number;
  26430. /**
  26431. * Defines that engine should ignore context lost events
  26432. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26433. */
  26434. doNotHandleContextLost?: boolean;
  26435. /**
  26436. * Defines that engine should ignore modifying touch action attribute and style
  26437. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26438. */
  26439. doNotHandleTouchAction?: boolean;
  26440. /**
  26441. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  26442. */
  26443. useHighPrecisionFloats?: boolean;
  26444. }
  26445. /**
  26446. * Defines the interface used by display changed events
  26447. */
  26448. export interface IDisplayChangedEventArgs {
  26449. /** Gets the vrDisplay object (if any) */
  26450. vrDisplay: Nullable<any>;
  26451. /** Gets a boolean indicating if webVR is supported */
  26452. vrSupported: boolean;
  26453. }
  26454. /**
  26455. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26456. */
  26457. export class Engine {
  26458. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26459. static ExceptionList: ({
  26460. key: string;
  26461. capture: string;
  26462. captureConstraint: number;
  26463. targets: string[];
  26464. } | {
  26465. key: string;
  26466. capture: null;
  26467. captureConstraint: null;
  26468. targets: string[];
  26469. })[];
  26470. /** Gets the list of created engines */
  26471. static readonly Instances: Engine[];
  26472. /**
  26473. * Gets the latest created engine
  26474. */
  26475. static readonly LastCreatedEngine: Nullable<Engine>;
  26476. /**
  26477. * Gets the latest created scene
  26478. */
  26479. static readonly LastCreatedScene: Nullable<Scene>;
  26480. /**
  26481. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26482. * @param flag defines which part of the materials must be marked as dirty
  26483. * @param predicate defines a predicate used to filter which materials should be affected
  26484. */
  26485. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26486. /**
  26487. * Hidden
  26488. */ private static _TextureLoaders: IInternalTextureLoader[];
  26489. /** Defines that alpha blending is disabled */
  26490. static readonly ALPHA_DISABLE: number;
  26491. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26492. static readonly ALPHA_ADD: number;
  26493. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26494. static readonly ALPHA_COMBINE: number;
  26495. /** Defines that alpha blending to DEST - SRC * DEST */
  26496. static readonly ALPHA_SUBTRACT: number;
  26497. /** Defines that alpha blending to SRC * DEST */
  26498. static readonly ALPHA_MULTIPLY: number;
  26499. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26500. static readonly ALPHA_MAXIMIZED: number;
  26501. /** Defines that alpha blending to SRC + DEST */
  26502. static readonly ALPHA_ONEONE: number;
  26503. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26504. static readonly ALPHA_PREMULTIPLIED: number;
  26505. /**
  26506. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26507. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26508. */
  26509. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  26510. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26511. static readonly ALPHA_INTERPOLATE: number;
  26512. /**
  26513. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26514. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26515. */
  26516. static readonly ALPHA_SCREENMODE: number;
  26517. /** Defines that the ressource is not delayed*/
  26518. static readonly DELAYLOADSTATE_NONE: number;
  26519. /** Defines that the ressource was successfully delay loaded */
  26520. static readonly DELAYLOADSTATE_LOADED: number;
  26521. /** Defines that the ressource is currently delay loading */
  26522. static readonly DELAYLOADSTATE_LOADING: number;
  26523. /** Defines that the ressource is delayed and has not started loading */
  26524. static readonly DELAYLOADSTATE_NOTLOADED: number;
  26525. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26526. static readonly NEVER: number;
  26527. /** 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 */
  26528. static readonly ALWAYS: number;
  26529. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  26530. static readonly LESS: number;
  26531. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  26532. static readonly EQUAL: number;
  26533. /** 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 */
  26534. static readonly LEQUAL: number;
  26535. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  26536. static readonly GREATER: number;
  26537. /** 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 */
  26538. static readonly GEQUAL: number;
  26539. /** 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 */
  26540. static readonly NOTEQUAL: number;
  26541. /** Passed to stencilOperation to specify that stencil value must be kept */
  26542. static readonly KEEP: number;
  26543. /** Passed to stencilOperation to specify that stencil value must be replaced */
  26544. static readonly REPLACE: number;
  26545. /** Passed to stencilOperation to specify that stencil value must be incremented */
  26546. static readonly INCR: number;
  26547. /** Passed to stencilOperation to specify that stencil value must be decremented */
  26548. static readonly DECR: number;
  26549. /** Passed to stencilOperation to specify that stencil value must be inverted */
  26550. static readonly INVERT: number;
  26551. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  26552. static readonly INCR_WRAP: number;
  26553. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  26554. static readonly DECR_WRAP: number;
  26555. /** Texture is not repeating outside of 0..1 UVs */
  26556. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  26557. /** Texture is repeating outside of 0..1 UVs */
  26558. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  26559. /** Texture is repeating and mirrored */
  26560. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  26561. /** ALPHA */
  26562. static readonly TEXTUREFORMAT_ALPHA: number;
  26563. /** LUMINANCE */
  26564. static readonly TEXTUREFORMAT_LUMINANCE: number;
  26565. /** LUMINANCE_ALPHA */
  26566. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  26567. /** RGB */
  26568. static readonly TEXTUREFORMAT_RGB: number;
  26569. /** RGBA */
  26570. static readonly TEXTUREFORMAT_RGBA: number;
  26571. /** RED */
  26572. static readonly TEXTUREFORMAT_RED: number;
  26573. /** RED (2nd reference) */
  26574. static readonly TEXTUREFORMAT_R: number;
  26575. /** RG */
  26576. static readonly TEXTUREFORMAT_RG: number;
  26577. /** RED_INTEGER */
  26578. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  26579. /** RED_INTEGER (2nd reference) */
  26580. static readonly TEXTUREFORMAT_R_INTEGER: number;
  26581. /** RG_INTEGER */
  26582. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  26583. /** RGB_INTEGER */
  26584. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  26585. /** RGBA_INTEGER */
  26586. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  26587. /** UNSIGNED_BYTE */
  26588. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  26589. /** UNSIGNED_BYTE (2nd reference) */
  26590. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  26591. /** FLOAT */
  26592. static readonly TEXTURETYPE_FLOAT: number;
  26593. /** HALF_FLOAT */
  26594. static readonly TEXTURETYPE_HALF_FLOAT: number;
  26595. /** BYTE */
  26596. static readonly TEXTURETYPE_BYTE: number;
  26597. /** SHORT */
  26598. static readonly TEXTURETYPE_SHORT: number;
  26599. /** UNSIGNED_SHORT */
  26600. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  26601. /** INT */
  26602. static readonly TEXTURETYPE_INT: number;
  26603. /** UNSIGNED_INT */
  26604. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  26605. /** UNSIGNED_SHORT_4_4_4_4 */
  26606. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  26607. /** UNSIGNED_SHORT_5_5_5_1 */
  26608. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  26609. /** UNSIGNED_SHORT_5_6_5 */
  26610. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  26611. /** UNSIGNED_INT_2_10_10_10_REV */
  26612. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  26613. /** UNSIGNED_INT_24_8 */
  26614. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  26615. /** UNSIGNED_INT_10F_11F_11F_REV */
  26616. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  26617. /** UNSIGNED_INT_5_9_9_9_REV */
  26618. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  26619. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  26620. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  26621. /** nearest is mag = nearest and min = nearest and mip = linear */
  26622. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  26623. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26624. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  26625. /** Trilinear is mag = linear and min = linear and mip = linear */
  26626. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  26627. /** nearest is mag = nearest and min = nearest and mip = linear */
  26628. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  26629. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26630. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  26631. /** Trilinear is mag = linear and min = linear and mip = linear */
  26632. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  26633. /** mag = nearest and min = nearest and mip = nearest */
  26634. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  26635. /** mag = nearest and min = linear and mip = nearest */
  26636. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  26637. /** mag = nearest and min = linear and mip = linear */
  26638. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  26639. /** mag = nearest and min = linear and mip = none */
  26640. static readonly TEXTURE_NEAREST_LINEAR: number;
  26641. /** mag = nearest and min = nearest and mip = none */
  26642. static readonly TEXTURE_NEAREST_NEAREST: number;
  26643. /** mag = linear and min = nearest and mip = nearest */
  26644. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  26645. /** mag = linear and min = nearest and mip = linear */
  26646. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  26647. /** mag = linear and min = linear and mip = none */
  26648. static readonly TEXTURE_LINEAR_LINEAR: number;
  26649. /** mag = linear and min = nearest and mip = none */
  26650. static readonly TEXTURE_LINEAR_NEAREST: number;
  26651. /** Explicit coordinates mode */
  26652. static readonly TEXTURE_EXPLICIT_MODE: number;
  26653. /** Spherical coordinates mode */
  26654. static readonly TEXTURE_SPHERICAL_MODE: number;
  26655. /** Planar coordinates mode */
  26656. static readonly TEXTURE_PLANAR_MODE: number;
  26657. /** Cubic coordinates mode */
  26658. static readonly TEXTURE_CUBIC_MODE: number;
  26659. /** Projection coordinates mode */
  26660. static readonly TEXTURE_PROJECTION_MODE: number;
  26661. /** Skybox coordinates mode */
  26662. static readonly TEXTURE_SKYBOX_MODE: number;
  26663. /** Inverse Cubic coordinates mode */
  26664. static readonly TEXTURE_INVCUBIC_MODE: number;
  26665. /** Equirectangular coordinates mode */
  26666. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  26667. /** Equirectangular Fixed coordinates mode */
  26668. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  26669. /** Equirectangular Fixed Mirrored coordinates mode */
  26670. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  26671. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  26672. static readonly SCALEMODE_FLOOR: number;
  26673. /** Defines that texture rescaling will look for the nearest power of 2 size */
  26674. static readonly SCALEMODE_NEAREST: number;
  26675. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  26676. static readonly SCALEMODE_CEILING: number;
  26677. /**
  26678. * Returns the current npm package of the sdk
  26679. */
  26680. static readonly NpmPackage: string;
  26681. /**
  26682. * Returns the current version of the framework
  26683. */
  26684. static readonly Version: string;
  26685. /**
  26686. * Returns a string describing the current engine
  26687. */
  26688. readonly description: string;
  26689. /**
  26690. * Gets or sets the epsilon value used by collision engine
  26691. */
  26692. static CollisionsEpsilon: number;
  26693. /**
  26694. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  26695. */
  26696. static ShadersRepository: string;
  26697. /**
  26698. * Method called to create the default loading screen.
  26699. * This can be overriden in your own app.
  26700. * @param canvas The rendering canvas element
  26701. * @returns The loading screen
  26702. */
  26703. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  26704. /**
  26705. * Method called to create the default rescale post process on each engine.
  26706. */ private static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  26707. /**
  26708. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  26709. */
  26710. forcePOTTextures: boolean;
  26711. /**
  26712. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  26713. */
  26714. isFullscreen: boolean;
  26715. /**
  26716. * Gets a boolean indicating if the pointer is currently locked
  26717. */
  26718. isPointerLock: boolean;
  26719. /**
  26720. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  26721. */
  26722. cullBackFaces: boolean;
  26723. /**
  26724. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  26725. */
  26726. renderEvenInBackground: boolean;
  26727. /**
  26728. * Gets or sets a boolean indicating that cache can be kept between frames
  26729. */
  26730. preventCacheWipeBetweenFrames: boolean;
  26731. /**
  26732. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  26733. **/
  26734. enableOfflineSupport: boolean;
  26735. /**
  26736. * 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)
  26737. **/
  26738. disableManifestCheck: boolean;
  26739. /**
  26740. * Gets the list of created scenes
  26741. */
  26742. scenes: Scene[];
  26743. /**
  26744. * Event raised when a new scene is created
  26745. */
  26746. onNewSceneAddedObservable: Observable<Scene>;
  26747. /**
  26748. * Gets the list of created postprocesses
  26749. */
  26750. postProcesses: PostProcess[];
  26751. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  26752. validateShaderPrograms: boolean;
  26753. /**
  26754. * Observable event triggered each time the rendering canvas is resized
  26755. */
  26756. onResizeObservable: Observable<Engine>;
  26757. /**
  26758. * Observable event triggered each time the canvas loses focus
  26759. */
  26760. onCanvasBlurObservable: Observable<Engine>;
  26761. /**
  26762. * Observable event triggered each time the canvas gains focus
  26763. */
  26764. onCanvasFocusObservable: Observable<Engine>;
  26765. /**
  26766. * Observable event triggered each time the canvas receives pointerout event
  26767. */
  26768. onCanvasPointerOutObservable: Observable<PointerEvent>;
  26769. /**
  26770. * Observable event triggered before each texture is initialized
  26771. */
  26772. onBeforeTextureInitObservable: Observable<Texture>;
  26773. private _vrDisplay;
  26774. private _vrSupported;
  26775. private _oldSize;
  26776. private _oldHardwareScaleFactor;
  26777. private _vrExclusivePointerMode;
  26778. private _webVRInitPromise;
  26779. /**
  26780. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  26781. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  26782. */
  26783. readonly isInVRExclusivePointerMode: boolean;
  26784. /**
  26785. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  26786. */
  26787. disableUniformBuffers: boolean;
  26788. /** @hidden */ uniformBuffers: UniformBuffer[];
  26789. /**
  26790. * Gets a boolean indicating that the engine supports uniform buffers
  26791. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  26792. */
  26793. readonly supportsUniformBuffers: boolean;
  26794. /**
  26795. * Observable raised when the engine begins a new frame
  26796. */
  26797. onBeginFrameObservable: Observable<Engine>;
  26798. /**
  26799. * If set, will be used to request the next animation frame for the render loop
  26800. */
  26801. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  26802. /**
  26803. * Observable raised when the engine ends the current frame
  26804. */
  26805. onEndFrameObservable: Observable<Engine>;
  26806. /**
  26807. * Observable raised when the engine is about to compile a shader
  26808. */
  26809. onBeforeShaderCompilationObservable: Observable<Engine>;
  26810. /**
  26811. * Observable raised when the engine has jsut compiled a shader
  26812. */
  26813. onAfterShaderCompilationObservable: Observable<Engine>;
  26814. /** @hidden */ gl: WebGLRenderingContext;
  26815. private _renderingCanvas;
  26816. private _windowIsBackground;
  26817. private _webGLVersion;
  26818. protected _highPrecisionShadersAllowed: boolean;
  26819. /** @hidden */ protected readonly _shouldUseHighPrecisionShader: boolean;
  26820. /**
  26821. * Gets a boolean indicating that only power of 2 textures are supported
  26822. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  26823. */
  26824. readonly needPOTTextures: boolean;
  26825. /** @hidden */ badOS: boolean;
  26826. /** @hidden */ badDesktopOS: boolean;
  26827. /**
  26828. * Gets the audio engine
  26829. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26830. * @ignorenaming
  26831. */
  26832. static audioEngine: IAudioEngine;
  26833. /**
  26834. * Default AudioEngine factory responsible of creating the Audio Engine.
  26835. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  26836. */
  26837. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  26838. /**
  26839. * Default offline support factory responsible of creating a tool used to store data locally.
  26840. * By default, this will create a Database object if the workload has been embedded.
  26841. */
  26842. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  26843. private _onFocus;
  26844. private _onBlur;
  26845. private _onCanvasPointerOut;
  26846. private _onCanvasBlur;
  26847. private _onCanvasFocus;
  26848. private _onFullscreenChange;
  26849. private _onPointerLockChange;
  26850. private _onVRDisplayPointerRestricted;
  26851. private _onVRDisplayPointerUnrestricted;
  26852. private _onVrDisplayConnect;
  26853. private _onVrDisplayDisconnect;
  26854. private _onVrDisplayPresentChange;
  26855. /**
  26856. * Observable signaled when VR display mode changes
  26857. */
  26858. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  26859. /**
  26860. * Observable signaled when VR request present is complete
  26861. */
  26862. onVRRequestPresentComplete: Observable<boolean>;
  26863. /**
  26864. * Observable signaled when VR request present starts
  26865. */
  26866. onVRRequestPresentStart: Observable<Engine>;
  26867. private _hardwareScalingLevel;
  26868. /** @hidden */
  26869. protected _caps: EngineCapabilities;
  26870. private _pointerLockRequested;
  26871. private _isStencilEnable;
  26872. private _colorWrite;
  26873. private _loadingScreen;
  26874. /** @hidden */ drawCalls: PerfCounter;
  26875. private _glVersion;
  26876. private _glRenderer;
  26877. private _glVendor;
  26878. private _videoTextureSupported;
  26879. private _renderingQueueLaunched;
  26880. private _activeRenderLoops;
  26881. private _deterministicLockstep;
  26882. private _lockstepMaxSteps;
  26883. /**
  26884. * Observable signaled when a context lost event is raised
  26885. */
  26886. onContextLostObservable: Observable<Engine>;
  26887. /**
  26888. * Observable signaled when a context restored event is raised
  26889. */
  26890. onContextRestoredObservable: Observable<Engine>;
  26891. private _onContextLost;
  26892. private _onContextRestored;
  26893. private _contextWasLost;
  26894. private _doNotHandleContextLost;
  26895. /**
  26896. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  26897. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  26898. */
  26899. doNotHandleContextLost: boolean;
  26900. private _performanceMonitor;
  26901. private _fps;
  26902. private _deltaTime;
  26903. /**
  26904. * Turn this value on if you want to pause FPS computation when in background
  26905. */
  26906. disablePerformanceMonitorInBackground: boolean;
  26907. /**
  26908. * Gets the performance monitor attached to this engine
  26909. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  26910. */
  26911. readonly performanceMonitor: PerformanceMonitor;
  26912. /**
  26913. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  26914. */
  26915. disableVertexArrayObjects: boolean;
  26916. /** @hidden */
  26917. protected _depthCullingState: _DepthCullingState;
  26918. /** @hidden */
  26919. protected _stencilState: _StencilState;
  26920. /** @hidden */
  26921. protected _alphaState: _AlphaState;
  26922. /** @hidden */
  26923. protected _alphaMode: number;
  26924. protected _internalTexturesCache: InternalTexture[];
  26925. /** @hidden */
  26926. protected _activeChannel: number;
  26927. private _currentTextureChannel;
  26928. /** @hidden */
  26929. protected _boundTexturesCache: {
  26930. [key: string]: Nullable<InternalTexture>;
  26931. };
  26932. /** @hidden */
  26933. protected _currentEffect: Nullable<Effect>;
  26934. /** @hidden */
  26935. protected _currentProgram: Nullable<WebGLProgram>;
  26936. private _compiledEffects;
  26937. private _vertexAttribArraysEnabled;
  26938. /** @hidden */
  26939. protected _cachedViewport: Nullable<Viewport>;
  26940. private _cachedVertexArrayObject;
  26941. /** @hidden */
  26942. protected _cachedVertexBuffers: any;
  26943. /** @hidden */
  26944. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  26945. /** @hidden */
  26946. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  26947. /** @hidden */
  26948. protected _currentRenderTarget: Nullable<InternalTexture>;
  26949. private _uintIndicesCurrentlySet;
  26950. private _currentBoundBuffer;
  26951. /** @hidden */
  26952. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  26953. private _currentBufferPointers;
  26954. private _currentInstanceLocations;
  26955. private _currentInstanceBuffers;
  26956. private _textureUnits;
  26957. private _workingCanvas;
  26958. private _workingContext;
  26959. private _rescalePostProcess;
  26960. private _dummyFramebuffer;
  26961. private _externalData;
  26962. private _bindedRenderFunction;
  26963. private _vaoRecordInProgress;
  26964. private _mustWipeVertexAttributes;
  26965. private _emptyTexture;
  26966. private _emptyCubeTexture;
  26967. private _emptyTexture3D;
  26968. /** @hidden */ frameHandler: number;
  26969. private _nextFreeTextureSlots;
  26970. private _maxSimultaneousTextures;
  26971. private _activeRequests;
  26972. private _texturesSupported;
  26973. private _textureFormatInUse;
  26974. /**
  26975. * Gets the list of texture formats supported
  26976. */
  26977. readonly texturesSupported: Array<string>;
  26978. /**
  26979. * Gets the list of texture formats in use
  26980. */
  26981. readonly textureFormatInUse: Nullable<string>;
  26982. /**
  26983. * Gets the current viewport
  26984. */
  26985. readonly currentViewport: Nullable<Viewport>;
  26986. /**
  26987. * Gets the default empty texture
  26988. */
  26989. readonly emptyTexture: InternalTexture;
  26990. /**
  26991. * Gets the default empty 3D texture
  26992. */
  26993. readonly emptyTexture3D: InternalTexture;
  26994. /**
  26995. * Gets the default empty cube texture
  26996. */
  26997. readonly emptyCubeTexture: InternalTexture;
  26998. /**
  26999. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27000. */
  27001. readonly premultipliedAlpha: boolean;
  27002. /**
  27003. * Creates a new engine
  27004. * @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
  27005. * @param antialias defines enable antialiasing (default: false)
  27006. * @param options defines further options to be sent to the getContext() function
  27007. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27008. */
  27009. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27010. private _disableTouchAction;
  27011. private _rebuildInternalTextures;
  27012. private _rebuildEffects;
  27013. /**
  27014. * Gets a boolean indicating if all created effects are ready
  27015. * @returns true if all effects are ready
  27016. */
  27017. areAllEffectsReady(): boolean;
  27018. private _rebuildBuffers;
  27019. private _initGLContext;
  27020. /**
  27021. * Gets version of the current webGL context
  27022. */
  27023. readonly webGLVersion: number;
  27024. /**
  27025. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27026. */
  27027. readonly isStencilEnable: boolean;
  27028. private _prepareWorkingCanvas;
  27029. /**
  27030. * Reset the texture cache to empty state
  27031. */
  27032. resetTextureCache(): void;
  27033. /**
  27034. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27035. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27036. * @returns true if engine is in deterministic lock step mode
  27037. */
  27038. isDeterministicLockStep(): boolean;
  27039. /**
  27040. * Gets the max steps when engine is running in deterministic lock step
  27041. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27042. * @returns the max steps
  27043. */
  27044. getLockstepMaxSteps(): number;
  27045. /**
  27046. * Gets an object containing information about the current webGL context
  27047. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27048. */
  27049. getGlInfo(): {
  27050. vendor: string;
  27051. renderer: string;
  27052. version: string;
  27053. };
  27054. /**
  27055. * Gets current aspect ratio
  27056. * @param camera defines the camera to use to get the aspect ratio
  27057. * @param useScreen defines if screen size must be used (or the current render target if any)
  27058. * @returns a number defining the aspect ratio
  27059. */
  27060. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27061. /**
  27062. * Gets current screen aspect ratio
  27063. * @returns a number defining the aspect ratio
  27064. */
  27065. getScreenAspectRatio(): number;
  27066. /**
  27067. * Gets the current render width
  27068. * @param useScreen defines if screen size must be used (or the current render target if any)
  27069. * @returns a number defining the current render width
  27070. */
  27071. getRenderWidth(useScreen?: boolean): number;
  27072. /**
  27073. * Gets the current render height
  27074. * @param useScreen defines if screen size must be used (or the current render target if any)
  27075. * @returns a number defining the current render height
  27076. */
  27077. getRenderHeight(useScreen?: boolean): number;
  27078. /**
  27079. * Gets the HTML canvas attached with the current webGL context
  27080. * @returns a HTML canvas
  27081. */
  27082. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27083. /**
  27084. * Gets the client rect of the HTML canvas attached with the current webGL context
  27085. * @returns a client rectanglee
  27086. */
  27087. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27088. /**
  27089. * Defines the hardware scaling level.
  27090. * By default the hardware scaling level is computed from the window device ratio.
  27091. * 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.
  27092. * @param level defines the level to use
  27093. */
  27094. setHardwareScalingLevel(level: number): void;
  27095. /**
  27096. * Gets the current hardware scaling level.
  27097. * By default the hardware scaling level is computed from the window device ratio.
  27098. * 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.
  27099. * @returns a number indicating the current hardware scaling level
  27100. */
  27101. getHardwareScalingLevel(): number;
  27102. /**
  27103. * Gets the list of loaded textures
  27104. * @returns an array containing all loaded textures
  27105. */
  27106. getLoadedTexturesCache(): InternalTexture[];
  27107. /**
  27108. * Gets the object containing all engine capabilities
  27109. * @returns the EngineCapabilities object
  27110. */
  27111. getCaps(): EngineCapabilities;
  27112. /**
  27113. * Gets the current depth function
  27114. * @returns a number defining the depth function
  27115. */
  27116. getDepthFunction(): Nullable<number>;
  27117. /**
  27118. * Sets the current depth function
  27119. * @param depthFunc defines the function to use
  27120. */
  27121. setDepthFunction(depthFunc: number): void;
  27122. /**
  27123. * Sets the current depth function to GREATER
  27124. */
  27125. setDepthFunctionToGreater(): void;
  27126. /**
  27127. * Sets the current depth function to GEQUAL
  27128. */
  27129. setDepthFunctionToGreaterOrEqual(): void;
  27130. /**
  27131. * Sets the current depth function to LESS
  27132. */
  27133. setDepthFunctionToLess(): void;
  27134. private _cachedStencilBuffer;
  27135. private _cachedStencilFunction;
  27136. private _cachedStencilMask;
  27137. private _cachedStencilOperationPass;
  27138. private _cachedStencilOperationFail;
  27139. private _cachedStencilOperationDepthFail;
  27140. private _cachedStencilReference;
  27141. /**
  27142. * Caches the the state of the stencil buffer
  27143. */
  27144. cacheStencilState(): void;
  27145. /**
  27146. * Restores the state of the stencil buffer
  27147. */
  27148. restoreStencilState(): void;
  27149. /**
  27150. * Sets the current depth function to LEQUAL
  27151. */
  27152. setDepthFunctionToLessOrEqual(): void;
  27153. /**
  27154. * Gets a boolean indicating if stencil buffer is enabled
  27155. * @returns the current stencil buffer state
  27156. */
  27157. getStencilBuffer(): boolean;
  27158. /**
  27159. * Enable or disable the stencil buffer
  27160. * @param enable defines if the stencil buffer must be enabled or disabled
  27161. */
  27162. setStencilBuffer(enable: boolean): void;
  27163. /**
  27164. * Gets the current stencil mask
  27165. * @returns a number defining the new stencil mask to use
  27166. */
  27167. getStencilMask(): number;
  27168. /**
  27169. * Sets the current stencil mask
  27170. * @param mask defines the new stencil mask to use
  27171. */
  27172. setStencilMask(mask: number): void;
  27173. /**
  27174. * Gets the current stencil function
  27175. * @returns a number defining the stencil function to use
  27176. */
  27177. getStencilFunction(): number;
  27178. /**
  27179. * Gets the current stencil reference value
  27180. * @returns a number defining the stencil reference value to use
  27181. */
  27182. getStencilFunctionReference(): number;
  27183. /**
  27184. * Gets the current stencil mask
  27185. * @returns a number defining the stencil mask to use
  27186. */
  27187. getStencilFunctionMask(): number;
  27188. /**
  27189. * Sets the current stencil function
  27190. * @param stencilFunc defines the new stencil function to use
  27191. */
  27192. setStencilFunction(stencilFunc: number): void;
  27193. /**
  27194. * Sets the current stencil reference
  27195. * @param reference defines the new stencil reference to use
  27196. */
  27197. setStencilFunctionReference(reference: number): void;
  27198. /**
  27199. * Sets the current stencil mask
  27200. * @param mask defines the new stencil mask to use
  27201. */
  27202. setStencilFunctionMask(mask: number): void;
  27203. /**
  27204. * Gets the current stencil operation when stencil fails
  27205. * @returns a number defining stencil operation to use when stencil fails
  27206. */
  27207. getStencilOperationFail(): number;
  27208. /**
  27209. * Gets the current stencil operation when depth fails
  27210. * @returns a number defining stencil operation to use when depth fails
  27211. */
  27212. getStencilOperationDepthFail(): number;
  27213. /**
  27214. * Gets the current stencil operation when stencil passes
  27215. * @returns a number defining stencil operation to use when stencil passes
  27216. */
  27217. getStencilOperationPass(): number;
  27218. /**
  27219. * Sets the stencil operation to use when stencil fails
  27220. * @param operation defines the stencil operation to use when stencil fails
  27221. */
  27222. setStencilOperationFail(operation: number): void;
  27223. /**
  27224. * Sets the stencil operation to use when depth fails
  27225. * @param operation defines the stencil operation to use when depth fails
  27226. */
  27227. setStencilOperationDepthFail(operation: number): void;
  27228. /**
  27229. * Sets the stencil operation to use when stencil passes
  27230. * @param operation defines the stencil operation to use when stencil passes
  27231. */
  27232. setStencilOperationPass(operation: number): void;
  27233. /**
  27234. * Sets a boolean indicating if the dithering state is enabled or disabled
  27235. * @param value defines the dithering state
  27236. */
  27237. setDitheringState(value: boolean): void;
  27238. /**
  27239. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27240. * @param value defines the rasterizer state
  27241. */
  27242. setRasterizerState(value: boolean): void;
  27243. /**
  27244. * stop executing a render loop function and remove it from the execution array
  27245. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27246. */
  27247. stopRenderLoop(renderFunction?: () => void): void;
  27248. /** @hidden */ renderLoop(): void;
  27249. /**
  27250. * Register and execute a render loop. The engine can have more than one render function
  27251. * @param renderFunction defines the function to continuously execute
  27252. */
  27253. runRenderLoop(renderFunction: () => void): void;
  27254. /**
  27255. * Toggle full screen mode
  27256. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27257. */
  27258. switchFullscreen(requestPointerLock: boolean): void;
  27259. /**
  27260. * Enters full screen mode
  27261. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27262. */
  27263. enterFullscreen(requestPointerLock: boolean): void;
  27264. /**
  27265. * Exits full screen mode
  27266. */
  27267. exitFullscreen(): void;
  27268. /**
  27269. * Clear the current render buffer or the current render target (if any is set up)
  27270. * @param color defines the color to use
  27271. * @param backBuffer defines if the back buffer must be cleared
  27272. * @param depth defines if the depth buffer must be cleared
  27273. * @param stencil defines if the stencil buffer must be cleared
  27274. */
  27275. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27276. /**
  27277. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27278. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27279. * @param y defines the y-coordinate of the corner of the clear rectangle
  27280. * @param width defines the width of the clear rectangle
  27281. * @param height defines the height of the clear rectangle
  27282. * @param clearColor defines the clear color
  27283. */
  27284. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27285. /**
  27286. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27287. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27288. * @param y defines the y-coordinate of the corner of the clear rectangle
  27289. * @param width defines the width of the clear rectangle
  27290. * @param height defines the height of the clear rectangle
  27291. */
  27292. enableScissor(x: number, y: number, width: number, height: number): void;
  27293. /**
  27294. * Disable previously set scissor test rectangle
  27295. */
  27296. disableScissor(): void;
  27297. private _viewportCached;
  27298. /** @hidden */ viewport(x: number, y: number, width: number, height: number): void;
  27299. /**
  27300. * Set the WebGL's viewport
  27301. * @param viewport defines the viewport element to be used
  27302. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27303. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27304. */
  27305. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27306. /**
  27307. * Directly set the WebGL Viewport
  27308. * @param x defines the x coordinate of the viewport (in screen space)
  27309. * @param y defines the y coordinate of the viewport (in screen space)
  27310. * @param width defines the width of the viewport (in screen space)
  27311. * @param height defines the height of the viewport (in screen space)
  27312. * @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
  27313. */
  27314. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27315. /**
  27316. * Begin a new frame
  27317. */
  27318. beginFrame(): void;
  27319. /**
  27320. * Enf the current frame
  27321. */
  27322. endFrame(): void;
  27323. /**
  27324. * Resize the view according to the canvas' size
  27325. */
  27326. resize(): void;
  27327. /**
  27328. * Force a specific size of the canvas
  27329. * @param width defines the new canvas' width
  27330. * @param height defines the new canvas' height
  27331. */
  27332. setSize(width: number, height: number): void;
  27333. /**
  27334. * Gets a boolean indicating if a webVR device was detected
  27335. * @returns true if a webVR device was detected
  27336. */
  27337. isVRDevicePresent(): boolean;
  27338. /**
  27339. * Gets the current webVR device
  27340. * @returns the current webVR device (or null)
  27341. */
  27342. getVRDevice(): any;
  27343. /**
  27344. * Initializes a webVR display and starts listening to display change events
  27345. * The onVRDisplayChangedObservable will be notified upon these changes
  27346. * @returns The onVRDisplayChangedObservable
  27347. */
  27348. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27349. /**
  27350. * Initializes a webVR display and starts listening to display change events
  27351. * The onVRDisplayChangedObservable will be notified upon these changes
  27352. * @returns A promise containing a VRDisplay and if vr is supported
  27353. */
  27354. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27355. /**
  27356. * Call this function to switch to webVR mode
  27357. * Will do nothing if webVR is not supported or if there is no webVR device
  27358. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27359. */
  27360. enableVR(): void;
  27361. /**
  27362. * Call this function to leave webVR mode
  27363. * Will do nothing if webVR is not supported or if there is no webVR device
  27364. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27365. */
  27366. disableVR(): void;
  27367. private _onVRFullScreenTriggered;
  27368. private _getVRDisplaysAsync;
  27369. /**
  27370. * Binds the frame buffer to the specified texture.
  27371. * @param texture The texture to render to or null for the default canvas
  27372. * @param faceIndex The face of the texture to render to in case of cube texture
  27373. * @param requiredWidth The width of the target to render to
  27374. * @param requiredHeight The height of the target to render to
  27375. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27376. * @param depthStencilTexture The depth stencil texture to use to render
  27377. * @param lodLevel defines le lod level to bind to the frame buffer
  27378. */
  27379. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27380. private bindUnboundFramebuffer;
  27381. /**
  27382. * Unbind the current render target texture from the webGL context
  27383. * @param texture defines the render target texture to unbind
  27384. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27385. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27386. */
  27387. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27388. /**
  27389. * Unbind a list of render target textures from the webGL context
  27390. * This is used only when drawBuffer extension or webGL2 are active
  27391. * @param textures defines the render target textures to unbind
  27392. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27393. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27394. */
  27395. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27396. /**
  27397. * Force the mipmap generation for the given render target texture
  27398. * @param texture defines the render target texture to use
  27399. */
  27400. generateMipMapsForCubemap(texture: InternalTexture): void;
  27401. /**
  27402. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27403. */
  27404. flushFramebuffer(): void;
  27405. /**
  27406. * Unbind the current render target and bind the default framebuffer
  27407. */
  27408. restoreDefaultFramebuffer(): void;
  27409. /**
  27410. * Create an uniform buffer
  27411. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27412. * @param elements defines the content of the uniform buffer
  27413. * @returns the webGL uniform buffer
  27414. */
  27415. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  27416. /**
  27417. * Create a dynamic uniform buffer
  27418. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27419. * @param elements defines the content of the uniform buffer
  27420. * @returns the webGL uniform buffer
  27421. */
  27422. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  27423. /**
  27424. * Update an existing uniform buffer
  27425. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27426. * @param uniformBuffer defines the target uniform buffer
  27427. * @param elements defines the content to update
  27428. * @param offset defines the offset in the uniform buffer where update should start
  27429. * @param count defines the size of the data to update
  27430. */
  27431. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27432. private _resetVertexBufferBinding;
  27433. /**
  27434. * Creates a vertex buffer
  27435. * @param data the data for the vertex buffer
  27436. * @returns the new WebGL static buffer
  27437. */
  27438. createVertexBuffer(data: DataArray): WebGLBuffer;
  27439. /**
  27440. * Creates a dynamic vertex buffer
  27441. * @param data the data for the dynamic vertex buffer
  27442. * @returns the new WebGL dynamic buffer
  27443. */
  27444. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  27445. /**
  27446. * Update a dynamic index buffer
  27447. * @param indexBuffer defines the target index buffer
  27448. * @param indices defines the data to update
  27449. * @param offset defines the offset in the target index buffer where update should start
  27450. */
  27451. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  27452. /**
  27453. * Updates a dynamic vertex buffer.
  27454. * @param vertexBuffer the vertex buffer to update
  27455. * @param data the data used to update the vertex buffer
  27456. * @param byteOffset the byte offset of the data
  27457. * @param byteLength the byte length of the data
  27458. */
  27459. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27460. private _resetIndexBufferBinding;
  27461. /**
  27462. * Creates a new index buffer
  27463. * @param indices defines the content of the index buffer
  27464. * @param updatable defines if the index buffer must be updatable
  27465. * @returns a new webGL buffer
  27466. */
  27467. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  27468. /**
  27469. * Bind a webGL buffer to the webGL context
  27470. * @param buffer defines the buffer to bind
  27471. */
  27472. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  27473. /**
  27474. * Bind an uniform buffer to the current webGL context
  27475. * @param buffer defines the buffer to bind
  27476. */
  27477. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  27478. /**
  27479. * Bind a buffer to the current webGL context at a given location
  27480. * @param buffer defines the buffer to bind
  27481. * @param location defines the index where to bind the buffer
  27482. */
  27483. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  27484. /**
  27485. * Bind a specific block at a given index in a specific shader program
  27486. * @param shaderProgram defines the shader program
  27487. * @param blockName defines the block name
  27488. * @param index defines the index where to bind the block
  27489. */
  27490. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  27491. private bindIndexBuffer;
  27492. private bindBuffer;
  27493. /**
  27494. * update the bound buffer with the given data
  27495. * @param data defines the data to update
  27496. */
  27497. updateArrayBuffer(data: Float32Array): void;
  27498. private _vertexAttribPointer;
  27499. private _bindIndexBufferWithCache;
  27500. private _bindVertexBuffersAttributes;
  27501. /**
  27502. * Records a vertex array object
  27503. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27504. * @param vertexBuffers defines the list of vertex buffers to store
  27505. * @param indexBuffer defines the index buffer to store
  27506. * @param effect defines the effect to store
  27507. * @returns the new vertex array object
  27508. */
  27509. recordVertexArrayObject(vertexBuffers: {
  27510. [key: string]: VertexBuffer;
  27511. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  27512. /**
  27513. * Bind a specific vertex array object
  27514. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27515. * @param vertexArrayObject defines the vertex array object to bind
  27516. * @param indexBuffer defines the index buffer to bind
  27517. */
  27518. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  27519. /**
  27520. * Bind webGl buffers directly to the webGL context
  27521. * @param vertexBuffer defines the vertex buffer to bind
  27522. * @param indexBuffer defines the index buffer to bind
  27523. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  27524. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  27525. * @param effect defines the effect associated with the vertex buffer
  27526. */
  27527. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  27528. private _unbindVertexArrayObject;
  27529. /**
  27530. * Bind a list of vertex buffers to the webGL context
  27531. * @param vertexBuffers defines the list of vertex buffers to bind
  27532. * @param indexBuffer defines the index buffer to bind
  27533. * @param effect defines the effect associated with the vertex buffers
  27534. */
  27535. bindBuffers(vertexBuffers: {
  27536. [key: string]: Nullable<VertexBuffer>;
  27537. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  27538. /**
  27539. * Unbind all instance attributes
  27540. */
  27541. unbindInstanceAttributes(): void;
  27542. /**
  27543. * Release and free the memory of a vertex array object
  27544. * @param vao defines the vertex array object to delete
  27545. */
  27546. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  27547. /** @hidden */ releaseBuffer(buffer: WebGLBuffer): boolean;
  27548. /**
  27549. * Creates a webGL buffer to use with instanciation
  27550. * @param capacity defines the size of the buffer
  27551. * @returns the webGL buffer
  27552. */
  27553. createInstancesBuffer(capacity: number): WebGLBuffer;
  27554. /**
  27555. * Delete a webGL buffer used with instanciation
  27556. * @param buffer defines the webGL buffer to delete
  27557. */
  27558. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  27559. /**
  27560. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  27561. * @param instancesBuffer defines the webGL buffer to update and bind
  27562. * @param data defines the data to store in the buffer
  27563. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  27564. */
  27565. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  27566. /**
  27567. * Apply all cached states (depth, culling, stencil and alpha)
  27568. */
  27569. applyStates(): void;
  27570. /**
  27571. * Send a draw order
  27572. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27573. * @param indexStart defines the starting index
  27574. * @param indexCount defines the number of index to draw
  27575. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27576. */
  27577. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  27578. /**
  27579. * Draw a list of points
  27580. * @param verticesStart defines the index of first vertex to draw
  27581. * @param verticesCount defines the count of vertices to draw
  27582. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27583. */
  27584. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27585. /**
  27586. * Draw a list of unindexed primitives
  27587. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27588. * @param verticesStart defines the index of first vertex to draw
  27589. * @param verticesCount defines the count of vertices to draw
  27590. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27591. */
  27592. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27593. /**
  27594. * Draw a list of indexed primitives
  27595. * @param fillMode defines the primitive to use
  27596. * @param indexStart defines the starting index
  27597. * @param indexCount defines the number of index to draw
  27598. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27599. */
  27600. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  27601. /**
  27602. * Draw a list of unindexed primitives
  27603. * @param fillMode defines the primitive to use
  27604. * @param verticesStart defines the index of first vertex to draw
  27605. * @param verticesCount defines the count of vertices to draw
  27606. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27607. */
  27608. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27609. private _drawMode;
  27610. /** @hidden */ releaseEffect(effect: Effect): void;
  27611. /** @hidden */ deleteProgram(program: WebGLProgram): void;
  27612. /**
  27613. * Create a new effect (used to store vertex/fragment shaders)
  27614. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  27615. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  27616. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  27617. * @param samplers defines an array of string used to represent textures
  27618. * @param defines defines the string containing the defines to use to compile the shaders
  27619. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  27620. * @param onCompiled defines a function to call when the effect creation is successful
  27621. * @param onError defines a function to call when the effect creation has failed
  27622. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  27623. * @returns the new Effect
  27624. */
  27625. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  27626. private _compileShader;
  27627. private _compileRawShader;
  27628. /**
  27629. * Directly creates a webGL program
  27630. * @param vertexCode defines the vertex shader code to use
  27631. * @param fragmentCode defines the fragment shader code to use
  27632. * @param context defines the webGL context to use (if not set, the current one will be used)
  27633. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27634. * @returns the new webGL program
  27635. */
  27636. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27637. /**
  27638. * Creates a webGL program
  27639. * @param vertexCode defines the vertex shader code to use
  27640. * @param fragmentCode defines the fragment shader code to use
  27641. * @param defines defines the string containing the defines to use to compile the shaders
  27642. * @param context defines the webGL context to use (if not set, the current one will be used)
  27643. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27644. * @returns the new webGL program
  27645. */
  27646. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27647. private _createShaderProgram;
  27648. private _finalizeProgram;
  27649. /** @hidden */ isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  27650. /** @hidden */ executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  27651. /**
  27652. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  27653. * @param shaderProgram defines the webGL program to use
  27654. * @param uniformsNames defines the list of uniform names
  27655. * @returns an array of webGL uniform locations
  27656. */
  27657. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  27658. /**
  27659. * Gets the lsit of active attributes for a given webGL program
  27660. * @param shaderProgram defines the webGL program to use
  27661. * @param attributesNames defines the list of attribute names to get
  27662. * @returns an array of indices indicating the offset of each attribute
  27663. */
  27664. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  27665. /**
  27666. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  27667. * @param effect defines the effect to activate
  27668. */
  27669. enableEffect(effect: Nullable<Effect>): void;
  27670. /**
  27671. * Set the value of an uniform to an array of int32
  27672. * @param uniform defines the webGL uniform location where to store the value
  27673. * @param array defines the array of int32 to store
  27674. */
  27675. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27676. /**
  27677. * Set the value of an uniform to an array of int32 (stored as vec2)
  27678. * @param uniform defines the webGL uniform location where to store the value
  27679. * @param array defines the array of int32 to store
  27680. */
  27681. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27682. /**
  27683. * Set the value of an uniform to an array of int32 (stored as vec3)
  27684. * @param uniform defines the webGL uniform location where to store the value
  27685. * @param array defines the array of int32 to store
  27686. */
  27687. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27688. /**
  27689. * Set the value of an uniform to an array of int32 (stored as vec4)
  27690. * @param uniform defines the webGL uniform location where to store the value
  27691. * @param array defines the array of int32 to store
  27692. */
  27693. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27694. /**
  27695. * Set the value of an uniform to an array of float32
  27696. * @param uniform defines the webGL uniform location where to store the value
  27697. * @param array defines the array of float32 to store
  27698. */
  27699. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27700. /**
  27701. * Set the value of an uniform to an array of float32 (stored as vec2)
  27702. * @param uniform defines the webGL uniform location where to store the value
  27703. * @param array defines the array of float32 to store
  27704. */
  27705. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27706. /**
  27707. * Set the value of an uniform to an array of float32 (stored as vec3)
  27708. * @param uniform defines the webGL uniform location where to store the value
  27709. * @param array defines the array of float32 to store
  27710. */
  27711. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27712. /**
  27713. * Set the value of an uniform to an array of float32 (stored as vec4)
  27714. * @param uniform defines the webGL uniform location where to store the value
  27715. * @param array defines the array of float32 to store
  27716. */
  27717. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27718. /**
  27719. * Set the value of an uniform to an array of number
  27720. * @param uniform defines the webGL uniform location where to store the value
  27721. * @param array defines the array of number to store
  27722. */
  27723. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27724. /**
  27725. * Set the value of an uniform to an array of number (stored as vec2)
  27726. * @param uniform defines the webGL uniform location where to store the value
  27727. * @param array defines the array of number to store
  27728. */
  27729. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27730. /**
  27731. * Set the value of an uniform to an array of number (stored as vec3)
  27732. * @param uniform defines the webGL uniform location where to store the value
  27733. * @param array defines the array of number to store
  27734. */
  27735. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27736. /**
  27737. * Set the value of an uniform to an array of number (stored as vec4)
  27738. * @param uniform defines the webGL uniform location where to store the value
  27739. * @param array defines the array of number to store
  27740. */
  27741. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27742. /**
  27743. * Set the value of an uniform to an array of float32 (stored as matrices)
  27744. * @param uniform defines the webGL uniform location where to store the value
  27745. * @param matrices defines the array of float32 to store
  27746. */
  27747. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  27748. /**
  27749. * Set the value of an uniform to a matrix
  27750. * @param uniform defines the webGL uniform location where to store the value
  27751. * @param matrix defines the matrix to store
  27752. */
  27753. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  27754. /**
  27755. * Set the value of an uniform to a matrix (3x3)
  27756. * @param uniform defines the webGL uniform location where to store the value
  27757. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  27758. */
  27759. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27760. /**
  27761. * Set the value of an uniform to a matrix (2x2)
  27762. * @param uniform defines the webGL uniform location where to store the value
  27763. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  27764. */
  27765. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27766. /**
  27767. * Set the value of an uniform to a number (int)
  27768. * @param uniform defines the webGL uniform location where to store the value
  27769. * @param value defines the int number to store
  27770. */
  27771. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  27772. /**
  27773. * Set the value of an uniform to a number (float)
  27774. * @param uniform defines the webGL uniform location where to store the value
  27775. * @param value defines the float number to store
  27776. */
  27777. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  27778. /**
  27779. * Set the value of an uniform to a vec2
  27780. * @param uniform defines the webGL uniform location where to store the value
  27781. * @param x defines the 1st component of the value
  27782. * @param y defines the 2nd component of the value
  27783. */
  27784. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  27785. /**
  27786. * Set the value of an uniform to a vec3
  27787. * @param uniform defines the webGL uniform location where to store the value
  27788. * @param x defines the 1st component of the value
  27789. * @param y defines the 2nd component of the value
  27790. * @param z defines the 3rd component of the value
  27791. */
  27792. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  27793. /**
  27794. * Set the value of an uniform to a boolean
  27795. * @param uniform defines the webGL uniform location where to store the value
  27796. * @param bool defines the boolean to store
  27797. */
  27798. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  27799. /**
  27800. * Set the value of an uniform to a vec4
  27801. * @param uniform defines the webGL uniform location where to store the value
  27802. * @param x defines the 1st component of the value
  27803. * @param y defines the 2nd component of the value
  27804. * @param z defines the 3rd component of the value
  27805. * @param w defines the 4th component of the value
  27806. */
  27807. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  27808. /**
  27809. * Set the value of an uniform to a Color3
  27810. * @param uniform defines the webGL uniform location where to store the value
  27811. * @param color3 defines the color to store
  27812. */
  27813. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  27814. /**
  27815. * Set the value of an uniform to a Color3 and an alpha value
  27816. * @param uniform defines the webGL uniform location where to store the value
  27817. * @param color3 defines the color to store
  27818. * @param alpha defines the alpha component to store
  27819. */
  27820. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  27821. /**
  27822. * Sets a Color4 on a uniform variable
  27823. * @param uniform defines the uniform location
  27824. * @param color4 defines the value to be set
  27825. */
  27826. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  27827. /**
  27828. * Set various states to the webGL context
  27829. * @param culling defines backface culling state
  27830. * @param zOffset defines the value to apply to zOffset (0 by default)
  27831. * @param force defines if states must be applied even if cache is up to date
  27832. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  27833. */
  27834. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  27835. /**
  27836. * Set the z offset to apply to current rendering
  27837. * @param value defines the offset to apply
  27838. */
  27839. setZOffset(value: number): void;
  27840. /**
  27841. * Gets the current value of the zOffset
  27842. * @returns the current zOffset state
  27843. */
  27844. getZOffset(): number;
  27845. /**
  27846. * Enable or disable depth buffering
  27847. * @param enable defines the state to set
  27848. */
  27849. setDepthBuffer(enable: boolean): void;
  27850. /**
  27851. * Gets a boolean indicating if depth writing is enabled
  27852. * @returns the current depth writing state
  27853. */
  27854. getDepthWrite(): boolean;
  27855. /**
  27856. * Enable or disable depth writing
  27857. * @param enable defines the state to set
  27858. */
  27859. setDepthWrite(enable: boolean): void;
  27860. /**
  27861. * Enable or disable color writing
  27862. * @param enable defines the state to set
  27863. */
  27864. setColorWrite(enable: boolean): void;
  27865. /**
  27866. * Gets a boolean indicating if color writing is enabled
  27867. * @returns the current color writing state
  27868. */
  27869. getColorWrite(): boolean;
  27870. /**
  27871. * Sets alpha constants used by some alpha blending modes
  27872. * @param r defines the red component
  27873. * @param g defines the green component
  27874. * @param b defines the blue component
  27875. * @param a defines the alpha component
  27876. */
  27877. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  27878. /**
  27879. * Sets the current alpha mode
  27880. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  27881. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  27882. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  27883. */
  27884. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  27885. /**
  27886. * Gets the current alpha mode
  27887. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  27888. * @returns the current alpha mode
  27889. */
  27890. getAlphaMode(): number;
  27891. /**
  27892. * Clears the list of texture accessible through engine.
  27893. * This can help preventing texture load conflict due to name collision.
  27894. */
  27895. clearInternalTexturesCache(): void;
  27896. /**
  27897. * Force the entire cache to be cleared
  27898. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  27899. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  27900. */
  27901. wipeCaches(bruteForce?: boolean): void;
  27902. /**
  27903. * Set the compressed texture format to use, based on the formats you have, and the formats
  27904. * supported by the hardware / browser.
  27905. *
  27906. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  27907. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  27908. * to API arguments needed to compressed textures. This puts the burden on the container
  27909. * generator to house the arcane code for determining these for current & future formats.
  27910. *
  27911. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  27912. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  27913. *
  27914. * Note: The result of this call is not taken into account when a texture is base64.
  27915. *
  27916. * @param formatsAvailable defines the list of those format families you have created
  27917. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  27918. *
  27919. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  27920. * @returns The extension selected.
  27921. */
  27922. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  27923. private _getSamplingParameters;
  27924. private _partialLoadImg;
  27925. private _cascadeLoadImgs;
  27926. /** @hidden */ createTexture(): WebGLTexture;
  27927. /**
  27928. * Usually called from Texture.ts.
  27929. * Passed information to create a WebGLTexture
  27930. * @param urlArg defines a value which contains one of the following:
  27931. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  27932. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  27933. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  27934. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  27935. * @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)
  27936. * @param scene needed for loading to the correct scene
  27937. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  27938. * @param onLoad optional callback to be called upon successful completion
  27939. * @param onError optional callback to be called upon failure
  27940. * @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
  27941. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  27942. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  27943. * @param forcedExtension defines the extension to use to pick the right loader
  27944. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  27945. * @returns a InternalTexture for assignment back into BABYLON.Texture
  27946. */
  27947. 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;
  27948. private _rescaleTexture;
  27949. /**
  27950. * Update a raw texture
  27951. * @param texture defines the texture to update
  27952. * @param data defines the data to store in the texture
  27953. * @param format defines the format of the data
  27954. * @param invertY defines if data must be stored with Y axis inverted
  27955. * @param compression defines the compression used (null by default)
  27956. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27957. */
  27958. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  27959. /**
  27960. * Creates a raw texture
  27961. * @param data defines the data to store in the texture
  27962. * @param width defines the width of the texture
  27963. * @param height defines the height of the texture
  27964. * @param format defines the format of the data
  27965. * @param generateMipMaps defines if the engine should generate the mip levels
  27966. * @param invertY defines if data must be stored with Y axis inverted
  27967. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  27968. * @param compression defines the compression used (null by default)
  27969. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27970. * @returns the raw texture inside an InternalTexture
  27971. */
  27972. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  27973. private _unpackFlipYCached;
  27974. /**
  27975. * In case you are sharing the context with other applications, it might
  27976. * be interested to not cache the unpack flip y state to ensure a consistent
  27977. * value would be set.
  27978. */
  27979. enableUnpackFlipYCached: boolean;
  27980. /** @hidden */ unpackFlipY(value: boolean): void;
  27981. /** @hidden */ getUnpackAlignement(): number;
  27982. /**
  27983. * Creates a dynamic texture
  27984. * @param width defines the width of the texture
  27985. * @param height defines the height of the texture
  27986. * @param generateMipMaps defines if the engine should generate the mip levels
  27987. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  27988. * @returns the dynamic texture inside an InternalTexture
  27989. */
  27990. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  27991. /**
  27992. * Update the sampling mode of a given texture
  27993. * @param samplingMode defines the required sampling mode
  27994. * @param texture defines the texture to update
  27995. */
  27996. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  27997. /**
  27998. * Update the content of a dynamic texture
  27999. * @param texture defines the texture to update
  28000. * @param canvas defines the canvas containing the source
  28001. * @param invertY defines if data must be stored with Y axis inverted
  28002. * @param premulAlpha defines if alpha is stored as premultiplied
  28003. * @param format defines the format of the data
  28004. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28005. */
  28006. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28007. /**
  28008. * Update a video texture
  28009. * @param texture defines the texture to update
  28010. * @param video defines the video element to use
  28011. * @param invertY defines if data must be stored with Y axis inverted
  28012. */
  28013. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28014. /**
  28015. * Updates a depth texture Comparison Mode and Function.
  28016. * If the comparison Function is equal to 0, the mode will be set to none.
  28017. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28018. * @param texture The texture to set the comparison function for
  28019. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28020. */
  28021. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28022. private _setupDepthStencilTexture;
  28023. /**
  28024. * Creates a depth stencil texture.
  28025. * This is only available in WebGL 2 or with the depth texture extension available.
  28026. * @param size The size of face edge in the texture.
  28027. * @param options The options defining the texture.
  28028. * @returns The texture
  28029. */
  28030. createDepthStencilTexture(size: number | {
  28031. width: number;
  28032. height: number;
  28033. }, options: DepthTextureCreationOptions): InternalTexture;
  28034. /**
  28035. * Creates a depth stencil texture.
  28036. * This is only available in WebGL 2 or with the depth texture extension available.
  28037. * @param size The size of face edge in the texture.
  28038. * @param options The options defining the texture.
  28039. * @returns The texture
  28040. */
  28041. private _createDepthStencilTexture;
  28042. /**
  28043. * Creates a depth stencil cube texture.
  28044. * This is only available in WebGL 2.
  28045. * @param size The size of face edge in the cube texture.
  28046. * @param options The options defining the cube texture.
  28047. * @returns The cube texture
  28048. */
  28049. private _createDepthStencilCubeTexture;
  28050. /**
  28051. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28052. * @param renderTarget The render target to set the frame buffer for
  28053. */
  28054. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28055. /**
  28056. * Creates a new render target texture
  28057. * @param size defines the size of the texture
  28058. * @param options defines the options used to create the texture
  28059. * @returns a new render target texture stored in an InternalTexture
  28060. */
  28061. createRenderTargetTexture(size: number | {
  28062. width: number;
  28063. height: number;
  28064. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28065. /**
  28066. * Create a multi render target texture
  28067. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28068. * @param size defines the size of the texture
  28069. * @param options defines the creation options
  28070. * @returns the cube texture as an InternalTexture
  28071. */
  28072. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28073. private _setupFramebufferDepthAttachments;
  28074. /**
  28075. * Updates the sample count of a render target texture
  28076. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28077. * @param texture defines the texture to update
  28078. * @param samples defines the sample count to set
  28079. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28080. */
  28081. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28082. /**
  28083. * Update the sample count for a given multiple render target texture
  28084. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28085. * @param textures defines the textures to update
  28086. * @param samples defines the sample count to set
  28087. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28088. */
  28089. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28090. /** @hidden */ uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28091. /** @hidden */ uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28092. /** @hidden */ uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28093. /** @hidden */ uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28094. /**
  28095. * Creates a new render target cube texture
  28096. * @param size defines the size of the texture
  28097. * @param options defines the options used to create the texture
  28098. * @returns a new render target cube texture stored in an InternalTexture
  28099. */
  28100. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  28101. /**
  28102. * Creates a cube texture
  28103. * @param rootUrl defines the url where the files to load is located
  28104. * @param scene defines the current scene
  28105. * @param files defines the list of files to load (1 per face)
  28106. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  28107. * @param onLoad defines an optional callback raised when the texture is loaded
  28108. * @param onError defines an optional callback raised if there is an issue to load the texture
  28109. * @param format defines the format of the data
  28110. * @param forcedExtension defines the extension to use to pick the right loader
  28111. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  28112. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  28113. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  28114. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  28115. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  28116. * @returns the cube texture as an InternalTexture
  28117. */
  28118. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  28119. /**
  28120. * @hidden
  28121. */ setCubeMapTextureParams(loadMipmap: boolean): void;
  28122. /**
  28123. * Update a raw cube texture
  28124. * @param texture defines the texture to udpdate
  28125. * @param data defines the data to store
  28126. * @param format defines the data format
  28127. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28128. * @param invertY defines if data must be stored with Y axis inverted
  28129. * @param compression defines the compression used (null by default)
  28130. * @param level defines which level of the texture to update
  28131. */
  28132. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  28133. /**
  28134. * Creates a new raw cube texture
  28135. * @param data defines the array of data to use to create each face
  28136. * @param size defines the size of the textures
  28137. * @param format defines the format of the data
  28138. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28139. * @param generateMipMaps defines if the engine should generate the mip levels
  28140. * @param invertY defines if data must be stored with Y axis inverted
  28141. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28142. * @param compression defines the compression used (null by default)
  28143. * @returns the cube texture as an InternalTexture
  28144. */
  28145. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  28146. /**
  28147. * Creates a new raw cube texture from a specified url
  28148. * @param url defines the url where the data is located
  28149. * @param scene defines the current scene
  28150. * @param size defines the size of the textures
  28151. * @param format defines the format of the data
  28152. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28153. * @param noMipmap defines if the engine should avoid generating the mip levels
  28154. * @param callback defines a callback used to extract texture data from loaded data
  28155. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  28156. * @param onLoad defines a callback called when texture is loaded
  28157. * @param onError defines a callback called if there is an error
  28158. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28159. * @param invertY defines if data must be stored with Y axis inverted
  28160. * @returns the cube texture as an InternalTexture
  28161. */
  28162. 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;
  28163. /**
  28164. * Update a raw 3D texture
  28165. * @param texture defines the texture to update
  28166. * @param data defines the data to store
  28167. * @param format defines the data format
  28168. * @param invertY defines if data must be stored with Y axis inverted
  28169. * @param compression defines the used compression (can be null)
  28170. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  28171. */
  28172. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  28173. /**
  28174. * Creates a new raw 3D texture
  28175. * @param data defines the data used to create the texture
  28176. * @param width defines the width of the texture
  28177. * @param height defines the height of the texture
  28178. * @param depth defines the depth of the texture
  28179. * @param format defines the format of the texture
  28180. * @param generateMipMaps defines if the engine must generate mip levels
  28181. * @param invertY defines if data must be stored with Y axis inverted
  28182. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28183. * @param compression defines the compressed used (can be null)
  28184. * @param textureType defines the compressed used (can be null)
  28185. * @returns a new raw 3D texture (stored in an InternalTexture)
  28186. */
  28187. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  28188. private _prepareWebGLTextureContinuation;
  28189. private _prepareWebGLTexture;
  28190. private _convertRGBtoRGBATextureData;
  28191. /** @hidden */ releaseFramebufferObjects(texture: InternalTexture): void;
  28192. /** @hidden */ releaseTexture(texture: InternalTexture): void;
  28193. private setProgram;
  28194. private _boundUniforms;
  28195. /**
  28196. * Binds an effect to the webGL context
  28197. * @param effect defines the effect to bind
  28198. */
  28199. bindSamplers(effect: Effect): void;
  28200. private _activateCurrentTexture;
  28201. /** @hidden */ bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28202. /** @hidden */ bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28203. /**
  28204. * Sets a texture to the webGL context from a postprocess
  28205. * @param channel defines the channel to use
  28206. * @param postProcess defines the source postprocess
  28207. */
  28208. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28209. /**
  28210. * Binds the output of the passed in post process to the texture channel specified
  28211. * @param channel The channel the texture should be bound to
  28212. * @param postProcess The post process which's output should be bound
  28213. */
  28214. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28215. /**
  28216. * Unbind all textures from the webGL context
  28217. */
  28218. unbindAllTextures(): void;
  28219. /**
  28220. * Sets a texture to the according uniform.
  28221. * @param channel The texture channel
  28222. * @param uniform The uniform to set
  28223. * @param texture The texture to apply
  28224. */
  28225. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28226. /**
  28227. * Sets a depth stencil texture from a render target to the according uniform.
  28228. * @param channel The texture channel
  28229. * @param uniform The uniform to set
  28230. * @param texture The render target texture containing the depth stencil texture to apply
  28231. */
  28232. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28233. private _bindSamplerUniformToChannel;
  28234. private _getTextureWrapMode;
  28235. private _setTexture;
  28236. /**
  28237. * Sets an array of texture to the webGL context
  28238. * @param channel defines the channel where the texture array must be set
  28239. * @param uniform defines the associated uniform location
  28240. * @param textures defines the array of textures to bind
  28241. */
  28242. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28243. /** @hidden */ setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28244. private _setTextureParameterFloat;
  28245. private _setTextureParameterInteger;
  28246. /**
  28247. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28248. * @param x defines the x coordinate of the rectangle where pixels must be read
  28249. * @param y defines the y coordinate of the rectangle where pixels must be read
  28250. * @param width defines the width of the rectangle where pixels must be read
  28251. * @param height defines the height of the rectangle where pixels must be read
  28252. * @returns a Uint8Array containing RGBA colors
  28253. */
  28254. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28255. /**
  28256. * Add an externaly attached data from its key.
  28257. * This method call will fail and return false, if such key already exists.
  28258. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28259. * @param key the unique key that identifies the data
  28260. * @param data the data object to associate to the key for this Engine instance
  28261. * @return true if no such key were already present and the data was added successfully, false otherwise
  28262. */
  28263. addExternalData<T>(key: string, data: T): boolean;
  28264. /**
  28265. * Get an externaly attached data from its key
  28266. * @param key the unique key that identifies the data
  28267. * @return the associated data, if present (can be null), or undefined if not present
  28268. */
  28269. getExternalData<T>(key: string): T;
  28270. /**
  28271. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28272. * @param key the unique key that identifies the data
  28273. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28274. * @return the associated data, can be null if the factory returned null.
  28275. */
  28276. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28277. /**
  28278. * Remove an externaly attached data from the Engine instance
  28279. * @param key the unique key that identifies the data
  28280. * @return true if the data was successfully removed, false if it doesn't exist
  28281. */
  28282. removeExternalData(key: string): boolean;
  28283. /**
  28284. * Unbind all vertex attributes from the webGL context
  28285. */
  28286. unbindAllAttributes(): void;
  28287. /**
  28288. * 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
  28289. */
  28290. releaseEffects(): void;
  28291. /**
  28292. * Dispose and release all associated resources
  28293. */
  28294. dispose(): void;
  28295. /**
  28296. * Display the loading screen
  28297. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28298. */
  28299. displayLoadingUI(): void;
  28300. /**
  28301. * Hide the loading screen
  28302. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28303. */
  28304. hideLoadingUI(): void;
  28305. /**
  28306. * Gets the current loading screen object
  28307. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28308. */
  28309. /**
  28310. * Sets the current loading screen object
  28311. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28312. */
  28313. loadingScreen: ILoadingScreen;
  28314. /**
  28315. * Sets the current loading screen text
  28316. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28317. */
  28318. loadingUIText: string;
  28319. /**
  28320. * Sets the current loading screen background color
  28321. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28322. */
  28323. loadingUIBackgroundColor: string;
  28324. /**
  28325. * Attach a new callback raised when context lost event is fired
  28326. * @param callback defines the callback to call
  28327. */
  28328. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28329. /**
  28330. * Attach a new callback raised when context restored event is fired
  28331. * @param callback defines the callback to call
  28332. */
  28333. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28334. /**
  28335. * Gets the source code of the vertex shader associated with a specific webGL program
  28336. * @param program defines the program to use
  28337. * @returns a string containing the source code of the vertex shader associated with the program
  28338. */
  28339. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28340. /**
  28341. * Gets the source code of the fragment shader associated with a specific webGL program
  28342. * @param program defines the program to use
  28343. * @returns a string containing the source code of the fragment shader associated with the program
  28344. */
  28345. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28346. /**
  28347. * Get the current error code of the webGL context
  28348. * @returns the error code
  28349. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28350. */
  28351. getError(): number;
  28352. /**
  28353. * Gets the current framerate
  28354. * @returns a number representing the framerate
  28355. */
  28356. getFps(): number;
  28357. /**
  28358. * Gets the time spent between current and previous frame
  28359. * @returns a number representing the delta time in ms
  28360. */
  28361. getDeltaTime(): number;
  28362. private _measureFps;
  28363. /** @hidden */ readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28364. private _canRenderToFloatFramebuffer;
  28365. private _canRenderToHalfFloatFramebuffer;
  28366. private _canRenderToFramebuffer;
  28367. /** @hidden */ getWebGLTextureType(type: number): number;
  28368. private _getInternalFormat;
  28369. /** @hidden */ getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28370. /** @hidden */ getRGBAMultiSampleBufferFormat(type: number): number;
  28371. /** @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;
  28372. /** @hidden */ loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28373. private _partialLoadFile;
  28374. private _cascadeLoadFiles;
  28375. /**
  28376. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28377. * @returns true if the engine can be created
  28378. * @ignorenaming
  28379. */
  28380. static isSupported(): boolean;
  28381. }
  28382. }
  28383. declare module BABYLON {
  28384. /**
  28385. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28386. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28387. */
  28388. export class EffectFallbacks {
  28389. private _defines;
  28390. private _currentRank;
  28391. private _maxRank;
  28392. private _mesh;
  28393. /**
  28394. * Removes the fallback from the bound mesh.
  28395. */
  28396. unBindMesh(): void;
  28397. /**
  28398. * Adds a fallback on the specified property.
  28399. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28400. * @param define The name of the define in the shader
  28401. */
  28402. addFallback(rank: number, define: string): void;
  28403. /**
  28404. * Sets the mesh to use CPU skinning when needing to fallback.
  28405. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28406. * @param mesh The mesh to use the fallbacks.
  28407. */
  28408. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28409. /**
  28410. * Checks to see if more fallbacks are still availible.
  28411. */
  28412. readonly isMoreFallbacks: boolean;
  28413. /**
  28414. * Removes the defines that shoould be removed when falling back.
  28415. * @param currentDefines defines the current define statements for the shader.
  28416. * @param effect defines the current effect we try to compile
  28417. * @returns The resulting defines with defines of the current rank removed.
  28418. */
  28419. reduce(currentDefines: string, effect: Effect): string;
  28420. }
  28421. /**
  28422. * Options to be used when creating an effect.
  28423. */
  28424. export class EffectCreationOptions {
  28425. /**
  28426. * Atrributes that will be used in the shader.
  28427. */
  28428. attributes: string[];
  28429. /**
  28430. * Uniform varible names that will be set in the shader.
  28431. */
  28432. uniformsNames: string[];
  28433. /**
  28434. * Uniform buffer varible names that will be set in the shader.
  28435. */
  28436. uniformBuffersNames: string[];
  28437. /**
  28438. * Sampler texture variable names that will be set in the shader.
  28439. */
  28440. samplers: string[];
  28441. /**
  28442. * Define statements that will be set in the shader.
  28443. */
  28444. defines: any;
  28445. /**
  28446. * Possible fallbacks for this effect to improve performance when needed.
  28447. */
  28448. fallbacks: Nullable<EffectFallbacks>;
  28449. /**
  28450. * Callback that will be called when the shader is compiled.
  28451. */
  28452. onCompiled: Nullable<(effect: Effect) => void>;
  28453. /**
  28454. * Callback that will be called if an error occurs during shader compilation.
  28455. */
  28456. onError: Nullable<(effect: Effect, errors: string) => void>;
  28457. /**
  28458. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28459. */
  28460. indexParameters: any;
  28461. /**
  28462. * Max number of lights that can be used in the shader.
  28463. */
  28464. maxSimultaneousLights: number;
  28465. /**
  28466. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28467. */
  28468. transformFeedbackVaryings: Nullable<string[]>;
  28469. }
  28470. /**
  28471. * Effect containing vertex and fragment shader that can be executed on an object.
  28472. */
  28473. export class Effect {
  28474. /**
  28475. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28476. */
  28477. static ShadersRepository: string;
  28478. /**
  28479. * Name of the effect.
  28480. */
  28481. name: any;
  28482. /**
  28483. * String container all the define statements that should be set on the shader.
  28484. */
  28485. defines: string;
  28486. /**
  28487. * Callback that will be called when the shader is compiled.
  28488. */
  28489. onCompiled: Nullable<(effect: Effect) => void>;
  28490. /**
  28491. * Callback that will be called if an error occurs during shader compilation.
  28492. */
  28493. onError: Nullable<(effect: Effect, errors: string) => void>;
  28494. /**
  28495. * Callback that will be called when effect is bound.
  28496. */
  28497. onBind: Nullable<(effect: Effect) => void>;
  28498. /**
  28499. * Unique ID of the effect.
  28500. */
  28501. uniqueId: number;
  28502. /**
  28503. * Observable that will be called when the shader is compiled.
  28504. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28505. */
  28506. onCompileObservable: Observable<Effect>;
  28507. /**
  28508. * Observable that will be called if an error occurs during shader compilation.
  28509. */
  28510. onErrorObservable: Observable<Effect>;
  28511. /** @hidden */ onBindObservable: Nullable<Observable<Effect>>;
  28512. /**
  28513. * Observable that will be called when effect is bound.
  28514. */
  28515. readonly onBindObservable: Observable<Effect>;
  28516. /** @hidden */ bonesComputationForcedToCPU: boolean;
  28517. private static _uniqueIdSeed;
  28518. private _engine;
  28519. private _uniformBuffersNames;
  28520. private _uniformsNames;
  28521. private _samplerList;
  28522. private _samplers;
  28523. private _isReady;
  28524. private _compilationError;
  28525. private _attributesNames;
  28526. private _attributes;
  28527. private _uniforms;
  28528. /**
  28529. * Key for the effect.
  28530. * @hidden
  28531. */ key: string;
  28532. private _indexParameters;
  28533. private _fallbacks;
  28534. private _vertexSourceCode;
  28535. private _fragmentSourceCode;
  28536. private _vertexSourceCodeOverride;
  28537. private _fragmentSourceCodeOverride;
  28538. private _transformFeedbackVaryings;
  28539. /**
  28540. * Compiled shader to webGL program.
  28541. * @hidden
  28542. */ program: WebGLProgram;
  28543. private _valueCache;
  28544. private static _baseCache;
  28545. /**
  28546. * Instantiates an effect.
  28547. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28548. * @param baseName Name of the effect.
  28549. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28550. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28551. * @param samplers List of sampler variables that will be passed to the shader.
  28552. * @param engine Engine to be used to render the effect
  28553. * @param defines Define statements to be added to the shader.
  28554. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28555. * @param onCompiled Callback that will be called when the shader is compiled.
  28556. * @param onError Callback that will be called if an error occurs during shader compilation.
  28557. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28558. */
  28559. 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);
  28560. /**
  28561. * Unique key for this effect
  28562. */
  28563. readonly key: string;
  28564. /**
  28565. * If the effect has been compiled and prepared.
  28566. * @returns if the effect is compiled and prepared.
  28567. */
  28568. isReady(): boolean;
  28569. /**
  28570. * The engine the effect was initialized with.
  28571. * @returns the engine.
  28572. */
  28573. getEngine(): Engine;
  28574. /**
  28575. * The compiled webGL program for the effect
  28576. * @returns the webGL program.
  28577. */
  28578. getProgram(): WebGLProgram;
  28579. /**
  28580. * The set of names of attribute variables for the shader.
  28581. * @returns An array of attribute names.
  28582. */
  28583. getAttributesNames(): string[];
  28584. /**
  28585. * Returns the attribute at the given index.
  28586. * @param index The index of the attribute.
  28587. * @returns The location of the attribute.
  28588. */
  28589. getAttributeLocation(index: number): number;
  28590. /**
  28591. * Returns the attribute based on the name of the variable.
  28592. * @param name of the attribute to look up.
  28593. * @returns the attribute location.
  28594. */
  28595. getAttributeLocationByName(name: string): number;
  28596. /**
  28597. * The number of attributes.
  28598. * @returns the numnber of attributes.
  28599. */
  28600. getAttributesCount(): number;
  28601. /**
  28602. * Gets the index of a uniform variable.
  28603. * @param uniformName of the uniform to look up.
  28604. * @returns the index.
  28605. */
  28606. getUniformIndex(uniformName: string): number;
  28607. /**
  28608. * Returns the attribute based on the name of the variable.
  28609. * @param uniformName of the uniform to look up.
  28610. * @returns the location of the uniform.
  28611. */
  28612. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28613. /**
  28614. * Returns an array of sampler variable names
  28615. * @returns The array of sampler variable neames.
  28616. */
  28617. getSamplers(): string[];
  28618. /**
  28619. * The error from the last compilation.
  28620. * @returns the error string.
  28621. */
  28622. getCompilationError(): string;
  28623. /**
  28624. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28625. * @param func The callback to be used.
  28626. */
  28627. executeWhenCompiled(func: (effect: Effect) => void): void;
  28628. private _checkIsReady;
  28629. /** @hidden */ loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28630. /** @hidden */ loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28631. /** @hidden */ dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28632. private _processShaderConversion;
  28633. private _processIncludes;
  28634. private _processPrecision;
  28635. /**
  28636. * Recompiles the webGL program
  28637. * @param vertexSourceCode The source code for the vertex shader.
  28638. * @param fragmentSourceCode The source code for the fragment shader.
  28639. * @param onCompiled Callback called when completed.
  28640. * @param onError Callback called on error.
  28641. * @hidden
  28642. */ rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  28643. /**
  28644. * Gets the uniform locations of the the specified variable names
  28645. * @param names THe names of the variables to lookup.
  28646. * @returns Array of locations in the same order as variable names.
  28647. */
  28648. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  28649. /**
  28650. * Prepares the effect
  28651. * @hidden
  28652. */ prepareEffect(): void;
  28653. /**
  28654. * Checks if the effect is supported. (Must be called after compilation)
  28655. */
  28656. readonly isSupported: boolean;
  28657. /**
  28658. * Binds a texture to the engine to be used as output of the shader.
  28659. * @param channel Name of the output variable.
  28660. * @param texture Texture to bind.
  28661. * @hidden
  28662. */ bindTexture(channel: string, texture: InternalTexture): void;
  28663. /**
  28664. * Sets a texture on the engine to be used in the shader.
  28665. * @param channel Name of the sampler variable.
  28666. * @param texture Texture to set.
  28667. */
  28668. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28669. /**
  28670. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28671. * @param channel Name of the sampler variable.
  28672. * @param texture Texture to set.
  28673. */
  28674. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28675. /**
  28676. * Sets an array of textures on the engine to be used in the shader.
  28677. * @param channel Name of the variable.
  28678. * @param textures Textures to set.
  28679. */
  28680. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28681. /**
  28682. * 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)
  28683. * @param channel Name of the sampler variable.
  28684. * @param postProcess Post process to get the input texture from.
  28685. */
  28686. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28687. /**
  28688. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28689. * 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)
  28690. * @param channel Name of the sampler variable.
  28691. * @param postProcess Post process to get the output texture from.
  28692. */
  28693. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28694. /** @hidden */ cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  28695. /** @hidden */ cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28696. /** @hidden */ cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28697. /** @hidden */ cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28698. /**
  28699. * Binds a buffer to a uniform.
  28700. * @param buffer Buffer to bind.
  28701. * @param name Name of the uniform variable to bind to.
  28702. */
  28703. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  28704. /**
  28705. * Binds block to a uniform.
  28706. * @param blockName Name of the block to bind.
  28707. * @param index Index to bind.
  28708. */
  28709. bindUniformBlock(blockName: string, index: number): void;
  28710. /**
  28711. * Sets an interger value on a uniform variable.
  28712. * @param uniformName Name of the variable.
  28713. * @param value Value to be set.
  28714. * @returns this effect.
  28715. */
  28716. setInt(uniformName: string, value: number): Effect;
  28717. /**
  28718. * Sets an int array on a uniform variable.
  28719. * @param uniformName Name of the variable.
  28720. * @param array array to be set.
  28721. * @returns this effect.
  28722. */
  28723. setIntArray(uniformName: string, array: Int32Array): Effect;
  28724. /**
  28725. * 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)
  28726. * @param uniformName Name of the variable.
  28727. * @param array array to be set.
  28728. * @returns this effect.
  28729. */
  28730. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28731. /**
  28732. * 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)
  28733. * @param uniformName Name of the variable.
  28734. * @param array array to be set.
  28735. * @returns this effect.
  28736. */
  28737. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28738. /**
  28739. * 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)
  28740. * @param uniformName Name of the variable.
  28741. * @param array array to be set.
  28742. * @returns this effect.
  28743. */
  28744. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28745. /**
  28746. * Sets an float array on a uniform variable.
  28747. * @param uniformName Name of the variable.
  28748. * @param array array to be set.
  28749. * @returns this effect.
  28750. */
  28751. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28752. /**
  28753. * 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)
  28754. * @param uniformName Name of the variable.
  28755. * @param array array to be set.
  28756. * @returns this effect.
  28757. */
  28758. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28759. /**
  28760. * 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)
  28761. * @param uniformName Name of the variable.
  28762. * @param array array to be set.
  28763. * @returns this effect.
  28764. */
  28765. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28766. /**
  28767. * 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)
  28768. * @param uniformName Name of the variable.
  28769. * @param array array to be set.
  28770. * @returns this effect.
  28771. */
  28772. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28773. /**
  28774. * Sets an array on a uniform variable.
  28775. * @param uniformName Name of the variable.
  28776. * @param array array to be set.
  28777. * @returns this effect.
  28778. */
  28779. setArray(uniformName: string, array: number[]): Effect;
  28780. /**
  28781. * 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)
  28782. * @param uniformName Name of the variable.
  28783. * @param array array to be set.
  28784. * @returns this effect.
  28785. */
  28786. setArray2(uniformName: string, array: number[]): Effect;
  28787. /**
  28788. * 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)
  28789. * @param uniformName Name of the variable.
  28790. * @param array array to be set.
  28791. * @returns this effect.
  28792. */
  28793. setArray3(uniformName: string, array: number[]): Effect;
  28794. /**
  28795. * 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)
  28796. * @param uniformName Name of the variable.
  28797. * @param array array to be set.
  28798. * @returns this effect.
  28799. */
  28800. setArray4(uniformName: string, array: number[]): Effect;
  28801. /**
  28802. * Sets matrices on a uniform variable.
  28803. * @param uniformName Name of the variable.
  28804. * @param matrices matrices to be set.
  28805. * @returns this effect.
  28806. */
  28807. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28808. /**
  28809. * Sets matrix on a uniform variable.
  28810. * @param uniformName Name of the variable.
  28811. * @param matrix matrix to be set.
  28812. * @returns this effect.
  28813. */
  28814. setMatrix(uniformName: string, matrix: Matrix): Effect;
  28815. /**
  28816. * 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)
  28817. * @param uniformName Name of the variable.
  28818. * @param matrix matrix to be set.
  28819. * @returns this effect.
  28820. */
  28821. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28822. /**
  28823. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28824. * @param uniformName Name of the variable.
  28825. * @param matrix matrix to be set.
  28826. * @returns this effect.
  28827. */
  28828. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28829. /**
  28830. * Sets a float on a uniform variable.
  28831. * @param uniformName Name of the variable.
  28832. * @param value value to be set.
  28833. * @returns this effect.
  28834. */
  28835. setFloat(uniformName: string, value: number): Effect;
  28836. /**
  28837. * Sets a boolean on a uniform variable.
  28838. * @param uniformName Name of the variable.
  28839. * @param bool value to be set.
  28840. * @returns this effect.
  28841. */
  28842. setBool(uniformName: string, bool: boolean): Effect;
  28843. /**
  28844. * Sets a Vector2 on a uniform variable.
  28845. * @param uniformName Name of the variable.
  28846. * @param vector2 vector2 to be set.
  28847. * @returns this effect.
  28848. */
  28849. setVector2(uniformName: string, vector2: Vector2): Effect;
  28850. /**
  28851. * Sets a float2 on a uniform variable.
  28852. * @param uniformName Name of the variable.
  28853. * @param x First float in float2.
  28854. * @param y Second float in float2.
  28855. * @returns this effect.
  28856. */
  28857. setFloat2(uniformName: string, x: number, y: number): Effect;
  28858. /**
  28859. * Sets a Vector3 on a uniform variable.
  28860. * @param uniformName Name of the variable.
  28861. * @param vector3 Value to be set.
  28862. * @returns this effect.
  28863. */
  28864. setVector3(uniformName: string, vector3: Vector3): Effect;
  28865. /**
  28866. * Sets a float3 on a uniform variable.
  28867. * @param uniformName Name of the variable.
  28868. * @param x First float in float3.
  28869. * @param y Second float in float3.
  28870. * @param z Third float in float3.
  28871. * @returns this effect.
  28872. */
  28873. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28874. /**
  28875. * Sets a Vector4 on a uniform variable.
  28876. * @param uniformName Name of the variable.
  28877. * @param vector4 Value to be set.
  28878. * @returns this effect.
  28879. */
  28880. setVector4(uniformName: string, vector4: Vector4): Effect;
  28881. /**
  28882. * Sets a float4 on a uniform variable.
  28883. * @param uniformName Name of the variable.
  28884. * @param x First float in float4.
  28885. * @param y Second float in float4.
  28886. * @param z Third float in float4.
  28887. * @param w Fourth float in float4.
  28888. * @returns this effect.
  28889. */
  28890. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28891. /**
  28892. * Sets a Color3 on a uniform variable.
  28893. * @param uniformName Name of the variable.
  28894. * @param color3 Value to be set.
  28895. * @returns this effect.
  28896. */
  28897. setColor3(uniformName: string, color3: Color3): Effect;
  28898. /**
  28899. * Sets a Color4 on a uniform variable.
  28900. * @param uniformName Name of the variable.
  28901. * @param color3 Value to be set.
  28902. * @param alpha Alpha value to be set.
  28903. * @returns this effect.
  28904. */
  28905. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  28906. /**
  28907. * Sets a Color4 on a uniform variable
  28908. * @param uniformName defines the name of the variable
  28909. * @param color4 defines the value to be set
  28910. * @returns this effect.
  28911. */
  28912. setDirectColor4(uniformName: string, color4: Color4): Effect;
  28913. /**
  28914. * This function will add a new shader to the shader store
  28915. * @param name the name of the shader
  28916. * @param pixelShader optional pixel shader content
  28917. * @param vertexShader optional vertex shader content
  28918. */
  28919. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28920. /**
  28921. * Store of each shader (The can be looked up using effect.key)
  28922. */
  28923. static ShadersStore: {
  28924. [key: string]: string;
  28925. };
  28926. /**
  28927. * Store of each included file for a shader (The can be looked up using effect.key)
  28928. */
  28929. static IncludesShadersStore: {
  28930. [key: string]: string;
  28931. };
  28932. /**
  28933. * Resets the cache of effects.
  28934. */
  28935. static ResetCache(): void;
  28936. }
  28937. }
  28938. declare module BABYLON {
  28939. /**
  28940. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28941. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28942. * 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;
  28943. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28944. */
  28945. export class ColorCurves {
  28946. private _dirty;
  28947. private _tempColor;
  28948. private _globalCurve;
  28949. private _highlightsCurve;
  28950. private _midtonesCurve;
  28951. private _shadowsCurve;
  28952. private _positiveCurve;
  28953. private _negativeCurve;
  28954. private _globalHue;
  28955. private _globalDensity;
  28956. private _globalSaturation;
  28957. private _globalExposure;
  28958. /**
  28959. * Gets the global Hue value.
  28960. * 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).
  28961. */
  28962. /**
  28963. * Sets the global Hue value.
  28964. * 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).
  28965. */
  28966. globalHue: number;
  28967. /**
  28968. * Gets the global Density value.
  28969. * 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.
  28970. * Values less than zero provide a filter of opposite hue.
  28971. */
  28972. /**
  28973. * Sets the global Density value.
  28974. * 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.
  28975. * Values less than zero provide a filter of opposite hue.
  28976. */
  28977. globalDensity: number;
  28978. /**
  28979. * Gets the global Saturation value.
  28980. * 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.
  28981. */
  28982. /**
  28983. * Sets the global Saturation value.
  28984. * 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.
  28985. */
  28986. globalSaturation: number;
  28987. /**
  28988. * Gets the global Exposure value.
  28989. * 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.
  28990. */
  28991. /**
  28992. * Sets the global Exposure value.
  28993. * 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.
  28994. */
  28995. globalExposure: number;
  28996. private _highlightsHue;
  28997. private _highlightsDensity;
  28998. private _highlightsSaturation;
  28999. private _highlightsExposure;
  29000. /**
  29001. * Gets the highlights Hue value.
  29002. * 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).
  29003. */
  29004. /**
  29005. * Sets the highlights Hue value.
  29006. * 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).
  29007. */
  29008. highlightsHue: number;
  29009. /**
  29010. * Gets the highlights Density value.
  29011. * 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.
  29012. * Values less than zero provide a filter of opposite hue.
  29013. */
  29014. /**
  29015. * Sets the highlights Density value.
  29016. * 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.
  29017. * Values less than zero provide a filter of opposite hue.
  29018. */
  29019. highlightsDensity: number;
  29020. /**
  29021. * Gets the highlights Saturation value.
  29022. * 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.
  29023. */
  29024. /**
  29025. * Sets the highlights Saturation value.
  29026. * 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.
  29027. */
  29028. highlightsSaturation: number;
  29029. /**
  29030. * Gets the highlights Exposure value.
  29031. * 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.
  29032. */
  29033. /**
  29034. * Sets the highlights Exposure value.
  29035. * 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.
  29036. */
  29037. highlightsExposure: number;
  29038. private _midtonesHue;
  29039. private _midtonesDensity;
  29040. private _midtonesSaturation;
  29041. private _midtonesExposure;
  29042. /**
  29043. * Gets the midtones Hue value.
  29044. * 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).
  29045. */
  29046. /**
  29047. * Sets the midtones Hue value.
  29048. * 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).
  29049. */
  29050. midtonesHue: number;
  29051. /**
  29052. * Gets the midtones Density value.
  29053. * 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.
  29054. * Values less than zero provide a filter of opposite hue.
  29055. */
  29056. /**
  29057. * Sets the midtones Density value.
  29058. * 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.
  29059. * Values less than zero provide a filter of opposite hue.
  29060. */
  29061. midtonesDensity: number;
  29062. /**
  29063. * Gets the midtones Saturation value.
  29064. * 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.
  29065. */
  29066. /**
  29067. * Sets the midtones Saturation value.
  29068. * 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.
  29069. */
  29070. midtonesSaturation: number;
  29071. /**
  29072. * Gets the midtones Exposure value.
  29073. * 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.
  29074. */
  29075. /**
  29076. * Sets the midtones Exposure value.
  29077. * 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.
  29078. */
  29079. midtonesExposure: number;
  29080. private _shadowsHue;
  29081. private _shadowsDensity;
  29082. private _shadowsSaturation;
  29083. private _shadowsExposure;
  29084. /**
  29085. * Gets the shadows Hue value.
  29086. * 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).
  29087. */
  29088. /**
  29089. * Sets the shadows Hue value.
  29090. * 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).
  29091. */
  29092. shadowsHue: number;
  29093. /**
  29094. * Gets the shadows Density value.
  29095. * 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.
  29096. * Values less than zero provide a filter of opposite hue.
  29097. */
  29098. /**
  29099. * Sets the shadows Density value.
  29100. * 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.
  29101. * Values less than zero provide a filter of opposite hue.
  29102. */
  29103. shadowsDensity: number;
  29104. /**
  29105. * Gets the shadows Saturation value.
  29106. * 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.
  29107. */
  29108. /**
  29109. * Sets the shadows Saturation value.
  29110. * 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.
  29111. */
  29112. shadowsSaturation: number;
  29113. /**
  29114. * Gets the shadows Exposure value.
  29115. * 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.
  29116. */
  29117. /**
  29118. * Sets the shadows Exposure value.
  29119. * 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.
  29120. */
  29121. shadowsExposure: number;
  29122. /**
  29123. * Returns the class name
  29124. * @returns The class name
  29125. */
  29126. getClassName(): string;
  29127. /**
  29128. * Binds the color curves to the shader.
  29129. * @param colorCurves The color curve to bind
  29130. * @param effect The effect to bind to
  29131. * @param positiveUniform The positive uniform shader parameter
  29132. * @param neutralUniform The neutral uniform shader parameter
  29133. * @param negativeUniform The negative uniform shader parameter
  29134. */
  29135. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29136. /**
  29137. * Prepare the list of uniforms associated with the ColorCurves effects.
  29138. * @param uniformsList The list of uniforms used in the effect
  29139. */
  29140. static PrepareUniforms(uniformsList: string[]): void;
  29141. /**
  29142. * Returns color grading data based on a hue, density, saturation and exposure value.
  29143. * @param filterHue The hue of the color filter.
  29144. * @param filterDensity The density of the color filter.
  29145. * @param saturation The saturation.
  29146. * @param exposure The exposure.
  29147. * @param result The result data container.
  29148. */
  29149. private getColorGradingDataToRef;
  29150. /**
  29151. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29152. * @param value The input slider value in range [-100,100].
  29153. * @returns Adjusted value.
  29154. */
  29155. private static applyColorGradingSliderNonlinear;
  29156. /**
  29157. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29158. * @param hue The hue (H) input.
  29159. * @param saturation The saturation (S) input.
  29160. * @param brightness The brightness (B) input.
  29161. * @result An RGBA color represented as Vector4.
  29162. */
  29163. private static fromHSBToRef;
  29164. /**
  29165. * Returns a value clamped between min and max
  29166. * @param value The value to clamp
  29167. * @param min The minimum of value
  29168. * @param max The maximum of value
  29169. * @returns The clamped value.
  29170. */
  29171. private static clamp;
  29172. /**
  29173. * Clones the current color curve instance.
  29174. * @return The cloned curves
  29175. */
  29176. clone(): ColorCurves;
  29177. /**
  29178. * Serializes the current color curve instance to a json representation.
  29179. * @return a JSON representation
  29180. */
  29181. serialize(): any;
  29182. /**
  29183. * Parses the color curve from a json representation.
  29184. * @param source the JSON source to parse
  29185. * @return The parsed curves
  29186. */
  29187. static Parse(source: any): ColorCurves;
  29188. }
  29189. }
  29190. declare module BABYLON {
  29191. /**
  29192. * Interface to follow in your material defines to integrate easily the
  29193. * Image proccessing functions.
  29194. * @hidden
  29195. */
  29196. export interface IImageProcessingConfigurationDefines {
  29197. IMAGEPROCESSING: boolean;
  29198. VIGNETTE: boolean;
  29199. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29200. VIGNETTEBLENDMODEOPAQUE: boolean;
  29201. TONEMAPPING: boolean;
  29202. TONEMAPPING_ACES: boolean;
  29203. CONTRAST: boolean;
  29204. EXPOSURE: boolean;
  29205. COLORCURVES: boolean;
  29206. COLORGRADING: boolean;
  29207. COLORGRADING3D: boolean;
  29208. SAMPLER3DGREENDEPTH: boolean;
  29209. SAMPLER3DBGRMAP: boolean;
  29210. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29211. }
  29212. /**
  29213. * @hidden
  29214. */
  29215. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29216. IMAGEPROCESSING: boolean;
  29217. VIGNETTE: boolean;
  29218. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29219. VIGNETTEBLENDMODEOPAQUE: boolean;
  29220. TONEMAPPING: boolean;
  29221. TONEMAPPING_ACES: boolean;
  29222. CONTRAST: boolean;
  29223. COLORCURVES: boolean;
  29224. COLORGRADING: boolean;
  29225. COLORGRADING3D: boolean;
  29226. SAMPLER3DGREENDEPTH: boolean;
  29227. SAMPLER3DBGRMAP: boolean;
  29228. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29229. EXPOSURE: boolean;
  29230. constructor();
  29231. }
  29232. /**
  29233. * This groups together the common properties used for image processing either in direct forward pass
  29234. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29235. * or not.
  29236. */
  29237. export class ImageProcessingConfiguration {
  29238. /**
  29239. * Default tone mapping applied in BabylonJS.
  29240. */
  29241. static readonly TONEMAPPING_STANDARD: number;
  29242. /**
  29243. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29244. * to other engines rendering to increase portability.
  29245. */
  29246. static readonly TONEMAPPING_ACES: number;
  29247. /**
  29248. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29249. */
  29250. colorCurves: Nullable<ColorCurves>;
  29251. private _colorCurvesEnabled;
  29252. /**
  29253. * Gets wether the color curves effect is enabled.
  29254. */
  29255. /**
  29256. * Sets wether the color curves effect is enabled.
  29257. */
  29258. colorCurvesEnabled: boolean;
  29259. private _colorGradingTexture;
  29260. /**
  29261. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29262. */
  29263. /**
  29264. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29265. */
  29266. colorGradingTexture: Nullable<BaseTexture>;
  29267. private _colorGradingEnabled;
  29268. /**
  29269. * Gets wether the color grading effect is enabled.
  29270. */
  29271. /**
  29272. * Sets wether the color grading effect is enabled.
  29273. */
  29274. colorGradingEnabled: boolean;
  29275. private _colorGradingWithGreenDepth;
  29276. /**
  29277. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29278. */
  29279. /**
  29280. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29281. */
  29282. colorGradingWithGreenDepth: boolean;
  29283. private _colorGradingBGR;
  29284. /**
  29285. * Gets wether the color grading texture contains BGR values.
  29286. */
  29287. /**
  29288. * Sets wether the color grading texture contains BGR values.
  29289. */
  29290. colorGradingBGR: boolean;
  29291. /** @hidden */ exposure: number;
  29292. /**
  29293. * Gets the Exposure used in the effect.
  29294. */
  29295. /**
  29296. * Sets the Exposure used in the effect.
  29297. */
  29298. exposure: number;
  29299. private _toneMappingEnabled;
  29300. /**
  29301. * Gets wether the tone mapping effect is enabled.
  29302. */
  29303. /**
  29304. * Sets wether the tone mapping effect is enabled.
  29305. */
  29306. toneMappingEnabled: boolean;
  29307. private _toneMappingType;
  29308. /**
  29309. * Gets the type of tone mapping effect.
  29310. */
  29311. /**
  29312. * Sets the type of tone mapping effect used in BabylonJS.
  29313. */
  29314. toneMappingType: number;
  29315. protected _contrast: number;
  29316. /**
  29317. * Gets the contrast used in the effect.
  29318. */
  29319. /**
  29320. * Sets the contrast used in the effect.
  29321. */
  29322. contrast: number;
  29323. /**
  29324. * Vignette stretch size.
  29325. */
  29326. vignetteStretch: number;
  29327. /**
  29328. * Vignette centre X Offset.
  29329. */
  29330. vignetteCentreX: number;
  29331. /**
  29332. * Vignette centre Y Offset.
  29333. */
  29334. vignetteCentreY: number;
  29335. /**
  29336. * Vignette weight or intensity of the vignette effect.
  29337. */
  29338. vignetteWeight: number;
  29339. /**
  29340. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29341. * if vignetteEnabled is set to true.
  29342. */
  29343. vignetteColor: Color4;
  29344. /**
  29345. * Camera field of view used by the Vignette effect.
  29346. */
  29347. vignetteCameraFov: number;
  29348. private _vignetteBlendMode;
  29349. /**
  29350. * Gets the vignette blend mode allowing different kind of effect.
  29351. */
  29352. /**
  29353. * Sets the vignette blend mode allowing different kind of effect.
  29354. */
  29355. vignetteBlendMode: number;
  29356. private _vignetteEnabled;
  29357. /**
  29358. * Gets wether the vignette effect is enabled.
  29359. */
  29360. /**
  29361. * Sets wether the vignette effect is enabled.
  29362. */
  29363. vignetteEnabled: boolean;
  29364. private _applyByPostProcess;
  29365. /**
  29366. * Gets wether the image processing is applied through a post process or not.
  29367. */
  29368. /**
  29369. * Sets wether the image processing is applied through a post process or not.
  29370. */
  29371. applyByPostProcess: boolean;
  29372. private _isEnabled;
  29373. /**
  29374. * Gets wether the image processing is enabled or not.
  29375. */
  29376. /**
  29377. * Sets wether the image processing is enabled or not.
  29378. */
  29379. isEnabled: boolean;
  29380. /**
  29381. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29382. */
  29383. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29384. /**
  29385. * Method called each time the image processing information changes requires to recompile the effect.
  29386. */
  29387. protected _updateParameters(): void;
  29388. /**
  29389. * Gets the current class name.
  29390. * @return "ImageProcessingConfiguration"
  29391. */
  29392. getClassName(): string;
  29393. /**
  29394. * Prepare the list of uniforms associated with the Image Processing effects.
  29395. * @param uniforms The list of uniforms used in the effect
  29396. * @param defines the list of defines currently in use
  29397. */
  29398. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29399. /**
  29400. * Prepare the list of samplers associated with the Image Processing effects.
  29401. * @param samplersList The list of uniforms used in the effect
  29402. * @param defines the list of defines currently in use
  29403. */
  29404. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29405. /**
  29406. * Prepare the list of defines associated to the shader.
  29407. * @param defines the list of defines to complete
  29408. * @param forPostProcess Define if we are currently in post process mode or not
  29409. */
  29410. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29411. /**
  29412. * Returns true if all the image processing information are ready.
  29413. * @returns True if ready, otherwise, false
  29414. */
  29415. isReady(): boolean;
  29416. /**
  29417. * Binds the image processing to the shader.
  29418. * @param effect The effect to bind to
  29419. * @param aspectRatio Define the current aspect ratio of the effect
  29420. */
  29421. bind(effect: Effect, aspectRatio?: number): void;
  29422. /**
  29423. * Clones the current image processing instance.
  29424. * @return The cloned image processing
  29425. */
  29426. clone(): ImageProcessingConfiguration;
  29427. /**
  29428. * Serializes the current image processing instance to a json representation.
  29429. * @return a JSON representation
  29430. */
  29431. serialize(): any;
  29432. /**
  29433. * Parses the image processing from a json representation.
  29434. * @param source the JSON source to parse
  29435. * @return The parsed image processing
  29436. */
  29437. static Parse(source: any): ImageProcessingConfiguration;
  29438. private static _VIGNETTEMODE_MULTIPLY;
  29439. private static _VIGNETTEMODE_OPAQUE;
  29440. /**
  29441. * Used to apply the vignette as a mix with the pixel color.
  29442. */
  29443. static readonly VIGNETTEMODE_MULTIPLY: number;
  29444. /**
  29445. * Used to apply the vignette as a replacement of the pixel color.
  29446. */
  29447. static readonly VIGNETTEMODE_OPAQUE: number;
  29448. }
  29449. }
  29450. declare module BABYLON {
  29451. /**
  29452. * This represents all the required information to add a fresnel effect on a material:
  29453. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29454. */
  29455. export class FresnelParameters {
  29456. private _isEnabled;
  29457. /**
  29458. * Define if the fresnel effect is enable or not.
  29459. */
  29460. isEnabled: boolean;
  29461. /**
  29462. * Define the color used on edges (grazing angle)
  29463. */
  29464. leftColor: Color3;
  29465. /**
  29466. * Define the color used on center
  29467. */
  29468. rightColor: Color3;
  29469. /**
  29470. * Define bias applied to computed fresnel term
  29471. */
  29472. bias: number;
  29473. /**
  29474. * Defined the power exponent applied to fresnel term
  29475. */
  29476. power: number;
  29477. /**
  29478. * Clones the current fresnel and its valuues
  29479. * @returns a clone fresnel configuration
  29480. */
  29481. clone(): FresnelParameters;
  29482. /**
  29483. * Serializes the current fresnel parameters to a JSON representation.
  29484. * @return the JSON serialization
  29485. */
  29486. serialize(): any;
  29487. /**
  29488. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29489. * @param parsedFresnelParameters Define the JSON representation
  29490. * @returns the parsed parameters
  29491. */
  29492. static Parse(parsedFresnelParameters: any): FresnelParameters;
  29493. }
  29494. }
  29495. declare module BABYLON {
  29496. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29497. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29498. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29499. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29500. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29501. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29502. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29503. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29504. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29505. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29506. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29507. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29508. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29509. /**
  29510. * Decorator used to define property that can be serialized as reference to a camera
  29511. * @param sourceName defines the name of the property to decorate
  29512. */
  29513. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29514. /**
  29515. * Class used to help serialization objects
  29516. */
  29517. export class SerializationHelper {
  29518. /** hidden */ private static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29519. /** hidden */ private static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29520. /** hidden */ private static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29521. /** hidden */ private static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29522. /**
  29523. * Appends the serialized animations from the source animations
  29524. * @param source Source containing the animations
  29525. * @param destination Target to store the animations
  29526. */
  29527. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29528. /**
  29529. * Static function used to serialized a specific entity
  29530. * @param entity defines the entity to serialize
  29531. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29532. * @returns a JSON compatible object representing the serialization of the entity
  29533. */
  29534. static Serialize<T>(entity: T, serializationObject?: any): any;
  29535. /**
  29536. * Creates a new entity from a serialization data object
  29537. * @param creationFunction defines a function used to instanciated the new entity
  29538. * @param source defines the source serialization data
  29539. * @param scene defines the hosting scene
  29540. * @param rootUrl defines the root url for resources
  29541. * @returns a new entity
  29542. */
  29543. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29544. /**
  29545. * Clones an object
  29546. * @param creationFunction defines the function used to instanciate the new object
  29547. * @param source defines the source object
  29548. * @returns the cloned object
  29549. */
  29550. static Clone<T>(creationFunction: () => T, source: T): T;
  29551. /**
  29552. * Instanciates a new object based on a source one (some data will be shared between both object)
  29553. * @param creationFunction defines the function used to instanciate the new object
  29554. * @param source defines the source object
  29555. * @returns the new object
  29556. */
  29557. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29558. }
  29559. }
  29560. declare module BABYLON {
  29561. /**
  29562. * This is the base class of all the camera used in the application.
  29563. * @see http://doc.babylonjs.com/features/cameras
  29564. */
  29565. export class Camera extends Node {
  29566. /** @hidden */ private static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29567. /**
  29568. * This is the default projection mode used by the cameras.
  29569. * It helps recreating a feeling of perspective and better appreciate depth.
  29570. * This is the best way to simulate real life cameras.
  29571. */
  29572. static readonly PERSPECTIVE_CAMERA: number;
  29573. /**
  29574. * This helps creating camera with an orthographic mode.
  29575. * 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.
  29576. */
  29577. static readonly ORTHOGRAPHIC_CAMERA: number;
  29578. /**
  29579. * This is the default FOV mode for perspective cameras.
  29580. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29581. */
  29582. static readonly FOVMODE_VERTICAL_FIXED: number;
  29583. /**
  29584. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29585. */
  29586. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29587. /**
  29588. * This specifies ther is no need for a camera rig.
  29589. * Basically only one eye is rendered corresponding to the camera.
  29590. */
  29591. static readonly RIG_MODE_NONE: number;
  29592. /**
  29593. * Simulates a camera Rig with one blue eye and one red eye.
  29594. * This can be use with 3d blue and red glasses.
  29595. */
  29596. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29597. /**
  29598. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29599. */
  29600. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29601. /**
  29602. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29603. */
  29604. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29605. /**
  29606. * Defines that both eyes of the camera will be rendered over under each other.
  29607. */
  29608. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29609. /**
  29610. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29611. */
  29612. static readonly RIG_MODE_VR: number;
  29613. /**
  29614. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29615. */
  29616. static readonly RIG_MODE_WEBVR: number;
  29617. /**
  29618. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29619. */
  29620. static readonly RIG_MODE_CUSTOM: number;
  29621. /**
  29622. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29623. */
  29624. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29625. /**
  29626. * Define the input manager associated with the camera.
  29627. */
  29628. inputs: CameraInputsManager<Camera>;
  29629. /** @hidden */ position: Vector3;
  29630. /**
  29631. * Define the current local position of the camera in the scene
  29632. */
  29633. position: Vector3;
  29634. /**
  29635. * The vector the camera should consider as up.
  29636. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29637. */
  29638. upVector: Vector3;
  29639. /**
  29640. * Define the current limit on the left side for an orthographic camera
  29641. * In scene unit
  29642. */
  29643. orthoLeft: Nullable<number>;
  29644. /**
  29645. * Define the current limit on the right side for an orthographic camera
  29646. * In scene unit
  29647. */
  29648. orthoRight: Nullable<number>;
  29649. /**
  29650. * Define the current limit on the bottom side for an orthographic camera
  29651. * In scene unit
  29652. */
  29653. orthoBottom: Nullable<number>;
  29654. /**
  29655. * Define the current limit on the top side for an orthographic camera
  29656. * In scene unit
  29657. */
  29658. orthoTop: Nullable<number>;
  29659. /**
  29660. * Field Of View is set in Radians. (default is 0.8)
  29661. */
  29662. fov: number;
  29663. /**
  29664. * Define the minimum distance the camera can see from.
  29665. * This is important to note that the depth buffer are not infinite and the closer it starts
  29666. * the more your scene might encounter depth fighting issue.
  29667. */
  29668. minZ: number;
  29669. /**
  29670. * Define the maximum distance the camera can see to.
  29671. * This is important to note that the depth buffer are not infinite and the further it end
  29672. * the more your scene might encounter depth fighting issue.
  29673. */
  29674. maxZ: number;
  29675. /**
  29676. * Define the default inertia of the camera.
  29677. * This helps giving a smooth feeling to the camera movement.
  29678. */
  29679. inertia: number;
  29680. /**
  29681. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  29682. */
  29683. mode: number;
  29684. /**
  29685. * Define wether the camera is intermediate.
  29686. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29687. */
  29688. isIntermediate: boolean;
  29689. /**
  29690. * Define the viewport of the camera.
  29691. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29692. */
  29693. viewport: Viewport;
  29694. /**
  29695. * Restricts the camera to viewing objects with the same layerMask.
  29696. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29697. */
  29698. layerMask: number;
  29699. /**
  29700. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29701. */
  29702. fovMode: number;
  29703. /**
  29704. * Rig mode of the camera.
  29705. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29706. * This is normally controlled byt the camera themselves as internal use.
  29707. */
  29708. cameraRigMode: number;
  29709. /**
  29710. * Defines the distance between both "eyes" in case of a RIG
  29711. */
  29712. interaxialDistance: number;
  29713. /**
  29714. * Defines if stereoscopic rendering is done side by side or over under.
  29715. */
  29716. isStereoscopicSideBySide: boolean;
  29717. /**
  29718. * 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
  29719. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29720. * else in the scene.
  29721. */
  29722. customRenderTargets: RenderTargetTexture[];
  29723. /**
  29724. * When set, the camera will render to this render target instead of the default canvas
  29725. */
  29726. outputRenderTarget: Nullable<RenderTargetTexture>;
  29727. /**
  29728. * Observable triggered when the camera view matrix has changed.
  29729. */
  29730. onViewMatrixChangedObservable: Observable<Camera>;
  29731. /**
  29732. * Observable triggered when the camera Projection matrix has changed.
  29733. */
  29734. onProjectionMatrixChangedObservable: Observable<Camera>;
  29735. /**
  29736. * Observable triggered when the inputs have been processed.
  29737. */
  29738. onAfterCheckInputsObservable: Observable<Camera>;
  29739. /**
  29740. * Observable triggered when reset has been called and applied to the camera.
  29741. */
  29742. onRestoreStateObservable: Observable<Camera>;
  29743. /** @hidden */ cameraRigParams: any;
  29744. /** @hidden */ rigCameras: Camera[];
  29745. /** @hidden */ rigPostProcess: Nullable<PostProcess>;
  29746. protected _webvrViewMatrix: Matrix;
  29747. /** @hidden */ skipRendering: boolean;
  29748. /** @hidden */ projectionMatrix: Matrix;
  29749. /** @hidden */ postProcesses: Nullable<PostProcess>[];
  29750. /** @hidden */ activeMeshes: SmartArray<AbstractMesh>;
  29751. protected _globalPosition: Vector3;
  29752. /** hidden */ computedViewMatrix: Matrix;
  29753. private _doNotComputeProjectionMatrix;
  29754. private _transformMatrix;
  29755. private _frustumPlanes;
  29756. private _refreshFrustumPlanes;
  29757. private _storedFov;
  29758. private _stateStored;
  29759. /**
  29760. * Instantiates a new camera object.
  29761. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29762. * @see http://doc.babylonjs.com/features/cameras
  29763. * @param name Defines the name of the camera in the scene
  29764. * @param position Defines the position of the camera
  29765. * @param scene Defines the scene the camera belongs too
  29766. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29767. */
  29768. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29769. /**
  29770. * Store current camera state (fov, position, etc..)
  29771. * @returns the camera
  29772. */
  29773. storeState(): Camera;
  29774. /**
  29775. * Restores the camera state values if it has been stored. You must call storeState() first
  29776. */
  29777. protected _restoreStateValues(): boolean;
  29778. /**
  29779. * Restored camera state. You must call storeState() first.
  29780. * @returns true if restored and false otherwise
  29781. */
  29782. restoreState(): boolean;
  29783. /**
  29784. * Gets the class name of the camera.
  29785. * @returns the class name
  29786. */
  29787. getClassName(): string;
  29788. /** @hidden */ protected readonly _isCamera: boolean;
  29789. /**
  29790. * Gets a string representation of the camera useful for debug purpose.
  29791. * @param fullDetails Defines that a more verboe level of logging is required
  29792. * @returns the string representation
  29793. */
  29794. toString(fullDetails?: boolean): string;
  29795. /**
  29796. * Gets the current world space position of the camera.
  29797. */
  29798. readonly globalPosition: Vector3;
  29799. /**
  29800. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29801. * @returns the active meshe list
  29802. */
  29803. getActiveMeshes(): SmartArray<AbstractMesh>;
  29804. /**
  29805. * Check wether a mesh is part of the current active mesh list of the camera
  29806. * @param mesh Defines the mesh to check
  29807. * @returns true if active, false otherwise
  29808. */
  29809. isActiveMesh(mesh: Mesh): boolean;
  29810. /**
  29811. * Is this camera ready to be used/rendered
  29812. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29813. * @return true if the camera is ready
  29814. */
  29815. isReady(completeCheck?: boolean): boolean;
  29816. /** @hidden */ initCache(): void;
  29817. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  29818. /** @hidden */ isSynchronized(): boolean;
  29819. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  29820. /** @hidden */ isSynchronizedProjectionMatrix(): boolean;
  29821. /**
  29822. * Attach the input controls to a specific dom element to get the input from.
  29823. * @param element Defines the element the controls should be listened from
  29824. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29825. */
  29826. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29827. /**
  29828. * Detach the current controls from the specified dom element.
  29829. * @param element Defines the element to stop listening the inputs from
  29830. */
  29831. detachControl(element: HTMLElement): void;
  29832. /**
  29833. * Update the camera state according to the different inputs gathered during the frame.
  29834. */
  29835. update(): void;
  29836. /** @hidden */ checkInputs(): void;
  29837. /** @hidden */
  29838. readonly rigCameras: Camera[];
  29839. /**
  29840. * Gets the post process used by the rig cameras
  29841. */
  29842. readonly rigPostProcess: Nullable<PostProcess>;
  29843. /**
  29844. * Internal, gets the first post proces.
  29845. * @returns the first post process to be run on this camera.
  29846. */ getFirstPostProcess(): Nullable<PostProcess>;
  29847. private _cascadePostProcessesToRigCams;
  29848. /**
  29849. * Attach a post process to the camera.
  29850. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29851. * @param postProcess The post process to attach to the camera
  29852. * @param insertAt The position of the post process in case several of them are in use in the scene
  29853. * @returns the position the post process has been inserted at
  29854. */
  29855. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29856. /**
  29857. * Detach a post process to the camera.
  29858. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29859. * @param postProcess The post process to detach from the camera
  29860. */
  29861. detachPostProcess(postProcess: PostProcess): void;
  29862. /**
  29863. * Gets the current world matrix of the camera
  29864. */
  29865. getWorldMatrix(): Matrix;
  29866. /** @hidden */ getViewMatrix(): Matrix;
  29867. /**
  29868. * Gets the current view matrix of the camera.
  29869. * @param force forces the camera to recompute the matrix without looking at the cached state
  29870. * @returns the view matrix
  29871. */
  29872. getViewMatrix(force?: boolean): Matrix;
  29873. /**
  29874. * Freeze the projection matrix.
  29875. * It will prevent the cache check of the camera projection compute and can speed up perf
  29876. * if no parameter of the camera are meant to change
  29877. * @param projection Defines manually a projection if necessary
  29878. */
  29879. freezeProjectionMatrix(projection?: Matrix): void;
  29880. /**
  29881. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29882. */
  29883. unfreezeProjectionMatrix(): void;
  29884. /**
  29885. * Gets the current projection matrix of the camera.
  29886. * @param force forces the camera to recompute the matrix without looking at the cached state
  29887. * @returns the projection matrix
  29888. */
  29889. getProjectionMatrix(force?: boolean): Matrix;
  29890. /**
  29891. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29892. * @returns a Matrix
  29893. */
  29894. getTransformationMatrix(): Matrix;
  29895. private _updateFrustumPlanes;
  29896. /**
  29897. * Checks if a cullable object (mesh...) is in the camera frustum
  29898. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29899. * @param target The object to check
  29900. * @returns true if the object is in frustum otherwise false
  29901. */
  29902. isInFrustum(target: ICullable): boolean;
  29903. /**
  29904. * Checks if a cullable object (mesh...) is in the camera frustum
  29905. * Unlike isInFrustum this cheks the full bounding box
  29906. * @param target The object to check
  29907. * @returns true if the object is in frustum otherwise false
  29908. */
  29909. isCompletelyInFrustum(target: ICullable): boolean;
  29910. /**
  29911. * Gets a ray in the forward direction from the camera.
  29912. * @param length Defines the length of the ray to create
  29913. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29914. * @param origin Defines the start point of the ray which defaults to the camera position
  29915. * @returns the forward ray
  29916. */
  29917. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29918. /**
  29919. * Releases resources associated with this node.
  29920. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29921. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29922. */
  29923. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29924. /** @hidden */ isLeftCamera: boolean;
  29925. /**
  29926. * Gets the left camera of a rig setup in case of Rigged Camera
  29927. */
  29928. readonly isLeftCamera: boolean;
  29929. /** @hidden */ isRightCamera: boolean;
  29930. /**
  29931. * Gets the right camera of a rig setup in case of Rigged Camera
  29932. */
  29933. readonly isRightCamera: boolean;
  29934. /**
  29935. * Gets the left camera of a rig setup in case of Rigged Camera
  29936. */
  29937. readonly leftCamera: Nullable<FreeCamera>;
  29938. /**
  29939. * Gets the right camera of a rig setup in case of Rigged Camera
  29940. */
  29941. readonly rightCamera: Nullable<FreeCamera>;
  29942. /**
  29943. * Gets the left camera target of a rig setup in case of Rigged Camera
  29944. * @returns the target position
  29945. */
  29946. getLeftTarget(): Nullable<Vector3>;
  29947. /**
  29948. * Gets the right camera target of a rig setup in case of Rigged Camera
  29949. * @returns the target position
  29950. */
  29951. getRightTarget(): Nullable<Vector3>;
  29952. /**
  29953. * @hidden
  29954. */
  29955. setCameraRigMode(mode: number, rigParams: any): void;
  29956. /** @hidden */ private static _setStereoscopicRigMode(camera: Camera): void;
  29957. /** @hidden */ private static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29958. /** @hidden */ private static _setVRRigMode(camera: Camera, rigParams: any): void;
  29959. /** @hidden */ private static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29960. /** @hidden */ getVRProjectionMatrix(): Matrix;
  29961. protected _updateCameraRotationMatrix(): void;
  29962. protected _updateWebVRCameraRotationMatrix(): void;
  29963. /**
  29964. * This function MUST be overwritten by the different WebVR cameras available.
  29965. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29966. * @hidden
  29967. */ getWebVRProjectionMatrix(): Matrix;
  29968. /**
  29969. * This function MUST be overwritten by the different WebVR cameras available.
  29970. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29971. * @hidden
  29972. */ getWebVRViewMatrix(): Matrix;
  29973. /** @hidden */
  29974. setCameraRigParameter(name: string, value: any): void;
  29975. /**
  29976. * needs to be overridden by children so sub has required properties to be copied
  29977. * @hidden
  29978. */
  29979. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29980. /**
  29981. * May need to be overridden by children
  29982. * @hidden
  29983. */ updateRigCameras(): void;
  29984. /** @hidden */ setupInputs(): void;
  29985. /**
  29986. * Serialiaze the camera setup to a json represention
  29987. * @returns the JSON representation
  29988. */
  29989. serialize(): any;
  29990. /**
  29991. * Clones the current camera.
  29992. * @param name The cloned camera name
  29993. * @returns the cloned camera
  29994. */
  29995. clone(name: string): Camera;
  29996. /**
  29997. * Gets the direction of the camera relative to a given local axis.
  29998. * @param localAxis Defines the reference axis to provide a relative direction.
  29999. * @return the direction
  30000. */
  30001. getDirection(localAxis: Vector3): Vector3;
  30002. /**
  30003. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30004. * @param localAxis Defines the reference axis to provide a relative direction.
  30005. * @param result Defines the vector to store the result in
  30006. */
  30007. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30008. /**
  30009. * Gets a camera constructor for a given camera type
  30010. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30011. * @param name The name of the camera the result will be able to instantiate
  30012. * @param scene The scene the result will construct the camera in
  30013. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30014. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30015. * @returns a factory method to construc the camera
  30016. */
  30017. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30018. /**
  30019. * Compute the world matrix of the camera.
  30020. * @returns the camera workd matrix
  30021. */
  30022. computeWorldMatrix(): Matrix;
  30023. /**
  30024. * Parse a JSON and creates the camera from the parsed information
  30025. * @param parsedCamera The JSON to parse
  30026. * @param scene The scene to instantiate the camera in
  30027. * @returns the newly constructed camera
  30028. */
  30029. static Parse(parsedCamera: any, scene: Scene): Camera;
  30030. }
  30031. }
  30032. declare module BABYLON {
  30033. /**
  30034. * Interface for any object that can request an animation frame
  30035. */
  30036. export interface ICustomAnimationFrameRequester {
  30037. /**
  30038. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30039. */
  30040. renderFunction?: Function;
  30041. /**
  30042. * Called to request the next frame to render to
  30043. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30044. */
  30045. requestAnimationFrame: Function;
  30046. /**
  30047. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30048. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30049. */
  30050. requestID?: number;
  30051. }
  30052. /**
  30053. * Interface containing an array of animations
  30054. */
  30055. export interface IAnimatable {
  30056. /**
  30057. * Array of animations
  30058. */
  30059. animations: Array<Animation>;
  30060. }
  30061. /** Interface used by value gradients (color, factor, ...) */
  30062. export interface IValueGradient {
  30063. /**
  30064. * Gets or sets the gradient value (between 0 and 1)
  30065. */
  30066. gradient: number;
  30067. }
  30068. /** Class used to store color4 gradient */
  30069. export class ColorGradient implements IValueGradient {
  30070. /**
  30071. * Gets or sets the gradient value (between 0 and 1)
  30072. */
  30073. gradient: number;
  30074. /**
  30075. * Gets or sets first associated color
  30076. */
  30077. color1: Color4;
  30078. /**
  30079. * Gets or sets second associated color
  30080. */
  30081. color2?: Color4;
  30082. /**
  30083. * Will get a color picked randomly between color1 and color2.
  30084. * If color2 is undefined then color1 will be used
  30085. * @param result defines the target Color4 to store the result in
  30086. */
  30087. getColorToRef(result: Color4): void;
  30088. }
  30089. /** Class used to store color 3 gradient */
  30090. export class Color3Gradient implements IValueGradient {
  30091. /**
  30092. * Gets or sets the gradient value (between 0 and 1)
  30093. */
  30094. gradient: number;
  30095. /**
  30096. * Gets or sets the associated color
  30097. */
  30098. color: Color3;
  30099. }
  30100. /** Class used to store factor gradient */
  30101. export class FactorGradient implements IValueGradient {
  30102. /**
  30103. * Gets or sets the gradient value (between 0 and 1)
  30104. */
  30105. gradient: number;
  30106. /**
  30107. * Gets or sets first associated factor
  30108. */
  30109. factor1: number;
  30110. /**
  30111. * Gets or sets second associated factor
  30112. */
  30113. factor2?: number;
  30114. /**
  30115. * Will get a number picked randomly between factor1 and factor2.
  30116. * If factor2 is undefined then factor1 will be used
  30117. * @returns the picked number
  30118. */
  30119. getFactor(): number;
  30120. }
  30121. /**
  30122. * @ignore
  30123. * Application error to support additional information when loading a file
  30124. */
  30125. export class LoadFileError extends Error {
  30126. /** defines the optional web request */
  30127. request?: WebRequest | undefined;
  30128. private static _setPrototypeOf;
  30129. /**
  30130. * Creates a new LoadFileError
  30131. * @param message defines the message of the error
  30132. * @param request defines the optional web request
  30133. */
  30134. constructor(message: string,
  30135. /** defines the optional web request */
  30136. request?: WebRequest | undefined);
  30137. }
  30138. /**
  30139. * Class used to define a retry strategy when error happens while loading assets
  30140. */
  30141. export class RetryStrategy {
  30142. /**
  30143. * Function used to defines an exponential back off strategy
  30144. * @param maxRetries defines the maximum number of retries (3 by default)
  30145. * @param baseInterval defines the interval between retries
  30146. * @returns the strategy function to use
  30147. */
  30148. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  30149. }
  30150. /**
  30151. * File request interface
  30152. */
  30153. export interface IFileRequest {
  30154. /**
  30155. * Raised when the request is complete (success or error).
  30156. */
  30157. onCompleteObservable: Observable<IFileRequest>;
  30158. /**
  30159. * Aborts the request for a file.
  30160. */
  30161. abort: () => void;
  30162. }
  30163. /**
  30164. * Class containing a set of static utilities functions
  30165. */
  30166. export class Tools {
  30167. /**
  30168. * Gets or sets the base URL to use to load assets
  30169. */
  30170. static BaseUrl: string;
  30171. /**
  30172. * Enable/Disable Custom HTTP Request Headers globally.
  30173. * default = false
  30174. * @see CustomRequestHeaders
  30175. */
  30176. static UseCustomRequestHeaders: boolean;
  30177. /**
  30178. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30179. * i.e. when loading files, where the server/service expects an Authorization header
  30180. */
  30181. static CustomRequestHeaders: {
  30182. [key: string]: string;
  30183. };
  30184. /**
  30185. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30186. */
  30187. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30188. /**
  30189. * Default behaviour for cors in the application.
  30190. * It can be a string if the expected behavior is identical in the entire app.
  30191. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30192. */
  30193. static CorsBehavior: string | ((url: string | string[]) => string);
  30194. /**
  30195. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30196. * @ignorenaming
  30197. */
  30198. static UseFallbackTexture: boolean;
  30199. /**
  30200. * Use this object to register external classes like custom textures or material
  30201. * to allow the laoders to instantiate them
  30202. */
  30203. static RegisteredExternalClasses: {
  30204. [key: string]: Object;
  30205. };
  30206. /**
  30207. * Texture content used if a texture cannot loaded
  30208. * @ignorenaming
  30209. */
  30210. static fallbackTexture: string;
  30211. /**
  30212. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30213. * @param u defines the coordinate on X axis
  30214. * @param v defines the coordinate on Y axis
  30215. * @param width defines the width of the source data
  30216. * @param height defines the height of the source data
  30217. * @param pixels defines the source byte array
  30218. * @param color defines the output color
  30219. */
  30220. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30221. /**
  30222. * Interpolates between a and b via alpha
  30223. * @param a The lower value (returned when alpha = 0)
  30224. * @param b The upper value (returned when alpha = 1)
  30225. * @param alpha The interpolation-factor
  30226. * @return The mixed value
  30227. */
  30228. static Mix(a: number, b: number, alpha: number): number;
  30229. /**
  30230. * Tries to instantiate a new object from a given class name
  30231. * @param className defines the class name to instantiate
  30232. * @returns the new object or null if the system was not able to do the instantiation
  30233. */
  30234. static Instantiate(className: string): any;
  30235. /**
  30236. * Provides a slice function that will work even on IE
  30237. * @param data defines the array to slice
  30238. * @param start defines the start of the data (optional)
  30239. * @param end defines the end of the data (optional)
  30240. * @returns the new sliced array
  30241. */
  30242. static Slice<T>(data: T, start?: number, end?: number): T;
  30243. /**
  30244. * Polyfill for setImmediate
  30245. * @param action defines the action to execute after the current execution block
  30246. */
  30247. static SetImmediate(action: () => void): void;
  30248. /**
  30249. * Function indicating if a number is an exponent of 2
  30250. * @param value defines the value to test
  30251. * @returns true if the value is an exponent of 2
  30252. */
  30253. static IsExponentOfTwo(value: number): boolean;
  30254. private static _tmpFloatArray;
  30255. /**
  30256. * Returns the nearest 32-bit single precision float representation of a Number
  30257. * @param value A Number. If the parameter is of a different type, it will get converted
  30258. * to a number or to NaN if it cannot be converted
  30259. * @returns number
  30260. */
  30261. static FloatRound(value: number): number;
  30262. /**
  30263. * Find the next highest power of two.
  30264. * @param x Number to start search from.
  30265. * @return Next highest power of two.
  30266. */
  30267. static CeilingPOT(x: number): number;
  30268. /**
  30269. * Find the next lowest power of two.
  30270. * @param x Number to start search from.
  30271. * @return Next lowest power of two.
  30272. */
  30273. static FloorPOT(x: number): number;
  30274. /**
  30275. * Find the nearest power of two.
  30276. * @param x Number to start search from.
  30277. * @return Next nearest power of two.
  30278. */
  30279. static NearestPOT(x: number): number;
  30280. /**
  30281. * Get the closest exponent of two
  30282. * @param value defines the value to approximate
  30283. * @param max defines the maximum value to return
  30284. * @param mode defines how to define the closest value
  30285. * @returns closest exponent of two of the given value
  30286. */
  30287. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30288. /**
  30289. * Extracts the filename from a path
  30290. * @param path defines the path to use
  30291. * @returns the filename
  30292. */
  30293. static GetFilename(path: string): string;
  30294. /**
  30295. * Extracts the "folder" part of a path (everything before the filename).
  30296. * @param uri The URI to extract the info from
  30297. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30298. * @returns The "folder" part of the path
  30299. */
  30300. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30301. /**
  30302. * Extracts text content from a DOM element hierarchy
  30303. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30304. */
  30305. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30306. /**
  30307. * Convert an angle in radians to degrees
  30308. * @param angle defines the angle to convert
  30309. * @returns the angle in degrees
  30310. */
  30311. static ToDegrees(angle: number): number;
  30312. /**
  30313. * Convert an angle in degrees to radians
  30314. * @param angle defines the angle to convert
  30315. * @returns the angle in radians
  30316. */
  30317. static ToRadians(angle: number): number;
  30318. /**
  30319. * Encode a buffer to a base64 string
  30320. * @param buffer defines the buffer to encode
  30321. * @returns the encoded string
  30322. */
  30323. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30324. /**
  30325. * Extracts minimum and maximum values from a list of indexed positions
  30326. * @param positions defines the positions to use
  30327. * @param indices defines the indices to the positions
  30328. * @param indexStart defines the start index
  30329. * @param indexCount defines the end index
  30330. * @param bias defines bias value to add to the result
  30331. * @return minimum and maximum values
  30332. */
  30333. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30334. minimum: Vector3;
  30335. maximum: Vector3;
  30336. };
  30337. /**
  30338. * Extracts minimum and maximum values from a list of positions
  30339. * @param positions defines the positions to use
  30340. * @param start defines the start index in the positions array
  30341. * @param count defines the number of positions to handle
  30342. * @param bias defines bias value to add to the result
  30343. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30344. * @return minimum and maximum values
  30345. */
  30346. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30347. minimum: Vector3;
  30348. maximum: Vector3;
  30349. };
  30350. /**
  30351. * Returns an array if obj is not an array
  30352. * @param obj defines the object to evaluate as an array
  30353. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30354. * @returns either obj directly if obj is an array or a new array containing obj
  30355. */
  30356. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30357. /**
  30358. * Gets the pointer prefix to use
  30359. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30360. */
  30361. static GetPointerPrefix(): string;
  30362. /**
  30363. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30364. * @param func - the function to be called
  30365. * @param requester - the object that will request the next frame. Falls back to window.
  30366. * @returns frame number
  30367. */
  30368. static QueueNewFrame(func: () => void, requester?: any): number;
  30369. /**
  30370. * Ask the browser to promote the current element to fullscreen rendering mode
  30371. * @param element defines the DOM element to promote
  30372. */
  30373. static RequestFullscreen(element: HTMLElement): void;
  30374. /**
  30375. * Asks the browser to exit fullscreen mode
  30376. */
  30377. static ExitFullscreen(): void;
  30378. /**
  30379. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30380. * @param url define the url we are trying
  30381. * @param element define the dom element where to configure the cors policy
  30382. */
  30383. static SetCorsBehavior(url: string | string[], element: {
  30384. crossOrigin: string | null;
  30385. }): void;
  30386. /**
  30387. * Removes unwanted characters from an url
  30388. * @param url defines the url to clean
  30389. * @returns the cleaned url
  30390. */
  30391. static CleanUrl(url: string): string;
  30392. /**
  30393. * Gets or sets a function used to pre-process url before using them to load assets
  30394. */
  30395. static PreprocessUrl: (url: string) => string;
  30396. /**
  30397. * Loads an image as an HTMLImageElement.
  30398. * @param input url string, ArrayBuffer, or Blob to load
  30399. * @param onLoad callback called when the image successfully loads
  30400. * @param onError callback called when the image fails to load
  30401. * @param offlineProvider offline provider for caching
  30402. * @returns the HTMLImageElement of the loaded image
  30403. */
  30404. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30405. /**
  30406. * Loads a file
  30407. * @param url url string, ArrayBuffer, or Blob to load
  30408. * @param onSuccess callback called when the file successfully loads
  30409. * @param onProgress callback called while file is loading (if the server supports this mode)
  30410. * @param offlineProvider defines the offline provider for caching
  30411. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  30412. * @param onError callback called when the file fails to load
  30413. * @returns a file request object
  30414. */
  30415. 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;
  30416. /**
  30417. * Load a script (identified by an url). When the url returns, the
  30418. * content of this file is added into a new script element, attached to the DOM (body element)
  30419. * @param scriptUrl defines the url of the script to laod
  30420. * @param onSuccess defines the callback called when the script is loaded
  30421. * @param onError defines the callback to call if an error occurs
  30422. * @param scriptId defines the id of the script element
  30423. */
  30424. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  30425. /**
  30426. * Load an asynchronous script (identified by an url). When the url returns, the
  30427. * content of this file is added into a new script element, attached to the DOM (body element)
  30428. * @param scriptUrl defines the url of the script to laod
  30429. * @param scriptId defines the id of the script element
  30430. * @returns a promise request object
  30431. */
  30432. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  30433. /**
  30434. * Loads a file from a blob
  30435. * @param fileToLoad defines the blob to use
  30436. * @param callback defines the callback to call when data is loaded
  30437. * @param progressCallback defines the callback to call during loading process
  30438. * @returns a file request object
  30439. */
  30440. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30441. /**
  30442. * Loads a file
  30443. * @param fileToLoad defines the file to load
  30444. * @param callback defines the callback to call when data is loaded
  30445. * @param progressCallBack defines the callback to call during loading process
  30446. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  30447. * @returns a file request object
  30448. */
  30449. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30450. /**
  30451. * Creates a data url from a given string content
  30452. * @param content defines the content to convert
  30453. * @returns the new data url link
  30454. */
  30455. static FileAsURL(content: string): string;
  30456. /**
  30457. * Format the given number to a specific decimal format
  30458. * @param value defines the number to format
  30459. * @param decimals defines the number of decimals to use
  30460. * @returns the formatted string
  30461. */
  30462. static Format(value: number, decimals?: number): string;
  30463. /**
  30464. * Checks if a given vector is inside a specific range
  30465. * @param v defines the vector to test
  30466. * @param min defines the minimum range
  30467. * @param max defines the maximum range
  30468. */
  30469. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30470. /**
  30471. * Tries to copy an object by duplicating every property
  30472. * @param source defines the source object
  30473. * @param destination defines the target object
  30474. * @param doNotCopyList defines a list of properties to avoid
  30475. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  30476. */
  30477. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30478. /**
  30479. * Gets a boolean indicating if the given object has no own property
  30480. * @param obj defines the object to test
  30481. * @returns true if object has no own property
  30482. */
  30483. static IsEmpty(obj: any): boolean;
  30484. /**
  30485. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  30486. * @param str Source string
  30487. * @param suffix Suffix to search for in the source string
  30488. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  30489. */
  30490. static EndsWith(str: string, suffix: string): boolean;
  30491. /**
  30492. * Function used to register events at window level
  30493. * @param events defines the events to register
  30494. */
  30495. static RegisterTopRootEvents(events: {
  30496. name: string;
  30497. handler: Nullable<(e: FocusEvent) => any>;
  30498. }[]): void;
  30499. /**
  30500. * Function used to unregister events from window level
  30501. * @param events defines the events to unregister
  30502. */
  30503. static UnregisterTopRootEvents(events: {
  30504. name: string;
  30505. handler: Nullable<(e: FocusEvent) => any>;
  30506. }[]): void;
  30507. /**
  30508. * @ignore
  30509. */ private static _ScreenshotCanvas: HTMLCanvasElement;
  30510. /**
  30511. * Dumps the current bound framebuffer
  30512. * @param width defines the rendering width
  30513. * @param height defines the rendering height
  30514. * @param engine defines the hosting engine
  30515. * @param successCallback defines the callback triggered once the data are available
  30516. * @param mimeType defines the mime type of the result
  30517. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  30518. */
  30519. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30520. /**
  30521. * Converts the canvas data to blob.
  30522. * This acts as a polyfill for browsers not supporting the to blob function.
  30523. * @param canvas Defines the canvas to extract the data from
  30524. * @param successCallback Defines the callback triggered once the data are available
  30525. * @param mimeType Defines the mime type of the result
  30526. */
  30527. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  30528. /**
  30529. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  30530. * @param successCallback defines the callback triggered once the data are available
  30531. * @param mimeType defines the mime type of the result
  30532. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  30533. */
  30534. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30535. /**
  30536. * Downloads a blob in the browser
  30537. * @param blob defines the blob to download
  30538. * @param fileName defines the name of the downloaded file
  30539. */
  30540. static Download(blob: Blob, fileName: string): void;
  30541. /**
  30542. * Captures a screenshot of the current rendering
  30543. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30544. * @param engine defines the rendering engine
  30545. * @param camera defines the source camera
  30546. * @param size This parameter can be set to a single number or to an object with the
  30547. * following (optional) properties: precision, width, height. If a single number is passed,
  30548. * it will be used for both width and height. If an object is passed, the screenshot size
  30549. * will be derived from the parameters. The precision property is a multiplier allowing
  30550. * rendering at a higher or lower resolution
  30551. * @param successCallback defines the callback receives a single parameter which contains the
  30552. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30553. * src parameter of an <img> to display it
  30554. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  30555. * Check your browser for supported MIME types
  30556. */
  30557. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  30558. /**
  30559. * Generates an image screenshot from the specified camera.
  30560. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30561. * @param engine The engine to use for rendering
  30562. * @param camera The camera to use for rendering
  30563. * @param size This parameter can be set to a single number or to an object with the
  30564. * following (optional) properties: precision, width, height. If a single number is passed,
  30565. * it will be used for both width and height. If an object is passed, the screenshot size
  30566. * will be derived from the parameters. The precision property is a multiplier allowing
  30567. * rendering at a higher or lower resolution
  30568. * @param successCallback The callback receives a single parameter which contains the
  30569. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30570. * src parameter of an <img> to display it
  30571. * @param mimeType The MIME type of the screenshot image (default: image/png).
  30572. * Check your browser for supported MIME types
  30573. * @param samples Texture samples (default: 1)
  30574. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  30575. * @param fileName A name for for the downloaded file.
  30576. */
  30577. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  30578. /**
  30579. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30580. * Be aware Math.random() could cause collisions, but:
  30581. * "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"
  30582. * @returns a pseudo random id
  30583. */
  30584. static RandomId(): string;
  30585. /**
  30586. * Test if the given uri is a base64 string
  30587. * @param uri The uri to test
  30588. * @return True if the uri is a base64 string or false otherwise
  30589. */
  30590. static IsBase64(uri: string): boolean;
  30591. /**
  30592. * Decode the given base64 uri.
  30593. * @param uri The uri to decode
  30594. * @return The decoded base64 data.
  30595. */
  30596. static DecodeBase64(uri: string): ArrayBuffer;
  30597. /**
  30598. * Gets the absolute url.
  30599. * @param url the input url
  30600. * @return the absolute url
  30601. */
  30602. static GetAbsoluteUrl(url: string): string;
  30603. /**
  30604. * No log
  30605. */
  30606. static readonly NoneLogLevel: number;
  30607. /**
  30608. * Only message logs
  30609. */
  30610. static readonly MessageLogLevel: number;
  30611. /**
  30612. * Only warning logs
  30613. */
  30614. static readonly WarningLogLevel: number;
  30615. /**
  30616. * Only error logs
  30617. */
  30618. static readonly ErrorLogLevel: number;
  30619. /**
  30620. * All logs
  30621. */
  30622. static readonly AllLogLevel: number;
  30623. /**
  30624. * Gets a value indicating the number of loading errors
  30625. * @ignorenaming
  30626. */
  30627. static readonly errorsCount: number;
  30628. /**
  30629. * Callback called when a new log is added
  30630. */
  30631. static OnNewCacheEntry: (entry: string) => void;
  30632. /**
  30633. * Log a message to the console
  30634. * @param message defines the message to log
  30635. */
  30636. static Log(message: string): void;
  30637. /**
  30638. * Write a warning message to the console
  30639. * @param message defines the message to log
  30640. */
  30641. static Warn(message: string): void;
  30642. /**
  30643. * Write an error message to the console
  30644. * @param message defines the message to log
  30645. */
  30646. static Error(message: string): void;
  30647. /**
  30648. * Gets current log cache (list of logs)
  30649. */
  30650. static readonly LogCache: string;
  30651. /**
  30652. * Clears the log cache
  30653. */
  30654. static ClearLogCache(): void;
  30655. /**
  30656. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  30657. */
  30658. static LogLevels: number;
  30659. /**
  30660. * Checks if the loaded document was accessed via `file:`-Protocol.
  30661. * @returns boolean
  30662. */
  30663. static IsFileURL(): boolean;
  30664. /**
  30665. * Checks if the window object exists
  30666. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  30667. */
  30668. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  30669. /**
  30670. * No performance log
  30671. */
  30672. static readonly PerformanceNoneLogLevel: number;
  30673. /**
  30674. * Use user marks to log performance
  30675. */
  30676. static readonly PerformanceUserMarkLogLevel: number;
  30677. /**
  30678. * Log performance to the console
  30679. */
  30680. static readonly PerformanceConsoleLogLevel: number;
  30681. private static _performance;
  30682. /**
  30683. * Sets the current performance log level
  30684. */
  30685. static PerformanceLogLevel: number;
  30686. private static _StartPerformanceCounterDisabled;
  30687. private static _EndPerformanceCounterDisabled;
  30688. private static _StartUserMark;
  30689. private static _EndUserMark;
  30690. private static _StartPerformanceConsole;
  30691. private static _EndPerformanceConsole;
  30692. /**
  30693. * Starts a performance counter
  30694. */
  30695. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30696. /**
  30697. * Ends a specific performance coutner
  30698. */
  30699. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30700. /**
  30701. * Gets either window.performance.now() if supported or Date.now() else
  30702. */
  30703. static readonly Now: number;
  30704. /**
  30705. * This method will return the name of the class used to create the instance of the given object.
  30706. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  30707. * @param object the object to get the class name from
  30708. * @param isType defines if the object is actually a type
  30709. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  30710. */
  30711. static GetClassName(object: any, isType?: boolean): string;
  30712. /**
  30713. * Gets the first element of an array satisfying a given predicate
  30714. * @param array defines the array to browse
  30715. * @param predicate defines the predicate to use
  30716. * @returns null if not found or the element
  30717. */
  30718. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  30719. /**
  30720. * This method will return the name of the full name of the class, including its owning module (if any).
  30721. * 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).
  30722. * @param object the object to get the class name from
  30723. * @param isType defines if the object is actually a type
  30724. * @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.
  30725. * @ignorenaming
  30726. */
  30727. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  30728. /**
  30729. * Returns a promise that resolves after the given amount of time.
  30730. * @param delay Number of milliseconds to delay
  30731. * @returns Promise that resolves after the given amount of time
  30732. */
  30733. static DelayAsync(delay: number): Promise<void>;
  30734. /**
  30735. * Gets the current gradient from an array of IValueGradient
  30736. * @param ratio defines the current ratio to get
  30737. * @param gradients defines the array of IValueGradient
  30738. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  30739. */
  30740. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  30741. }
  30742. /**
  30743. * This class is used to track a performance counter which is number based.
  30744. * The user has access to many properties which give statistics of different nature.
  30745. *
  30746. * The implementer can track two kinds of Performance Counter: time and count.
  30747. * 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.
  30748. * 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.
  30749. */
  30750. export class PerfCounter {
  30751. /**
  30752. * Gets or sets a global boolean to turn on and off all the counters
  30753. */
  30754. static Enabled: boolean;
  30755. /**
  30756. * Returns the smallest value ever
  30757. */
  30758. readonly min: number;
  30759. /**
  30760. * Returns the biggest value ever
  30761. */
  30762. readonly max: number;
  30763. /**
  30764. * Returns the average value since the performance counter is running
  30765. */
  30766. readonly average: number;
  30767. /**
  30768. * Returns the average value of the last second the counter was monitored
  30769. */
  30770. readonly lastSecAverage: number;
  30771. /**
  30772. * Returns the current value
  30773. */
  30774. readonly current: number;
  30775. /**
  30776. * Gets the accumulated total
  30777. */
  30778. readonly total: number;
  30779. /**
  30780. * Gets the total value count
  30781. */
  30782. readonly count: number;
  30783. /**
  30784. * Creates a new counter
  30785. */
  30786. constructor();
  30787. /**
  30788. * Call this method to start monitoring a new frame.
  30789. * 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.
  30790. */
  30791. fetchNewFrame(): void;
  30792. /**
  30793. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30794. * @param newCount the count value to add to the monitored count
  30795. * @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.
  30796. */
  30797. addCount(newCount: number, fetchResult: boolean): void;
  30798. /**
  30799. * Start monitoring this performance counter
  30800. */
  30801. beginMonitoring(): void;
  30802. /**
  30803. * Compute the time lapsed since the previous beginMonitoring() call.
  30804. * @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
  30805. */
  30806. endMonitoring(newFrame?: boolean): void;
  30807. private _fetchResult;
  30808. private _startMonitoringTime;
  30809. private _min;
  30810. private _max;
  30811. private _average;
  30812. private _current;
  30813. private _totalValueCount;
  30814. private _totalAccumulated;
  30815. private _lastSecAverage;
  30816. private _lastSecAccumulated;
  30817. private _lastSecTime;
  30818. private _lastSecValueCount;
  30819. }
  30820. /**
  30821. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  30822. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  30823. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  30824. * @param name The name of the class, case should be preserved
  30825. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  30826. */
  30827. export function className(name: string, module?: string): (target: Object) => void;
  30828. /**
  30829. * An implementation of a loop for asynchronous functions.
  30830. */
  30831. export class AsyncLoop {
  30832. /**
  30833. * Defines the number of iterations for the loop
  30834. */
  30835. iterations: number;
  30836. /**
  30837. * Defines the current index of the loop.
  30838. */
  30839. index: number;
  30840. private _done;
  30841. private _fn;
  30842. private _successCallback;
  30843. /**
  30844. * Constructor.
  30845. * @param iterations the number of iterations.
  30846. * @param func the function to run each iteration
  30847. * @param successCallback the callback that will be called upon succesful execution
  30848. * @param offset starting offset.
  30849. */
  30850. constructor(
  30851. /**
  30852. * Defines the number of iterations for the loop
  30853. */
  30854. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  30855. /**
  30856. * Execute the next iteration. Must be called after the last iteration was finished.
  30857. */
  30858. executeNext(): void;
  30859. /**
  30860. * Break the loop and run the success callback.
  30861. */
  30862. breakLoop(): void;
  30863. /**
  30864. * Create and run an async loop.
  30865. * @param iterations the number of iterations.
  30866. * @param fn the function to run each iteration
  30867. * @param successCallback the callback that will be called upon succesful execution
  30868. * @param offset starting offset.
  30869. * @returns the created async loop object
  30870. */
  30871. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  30872. /**
  30873. * A for-loop that will run a given number of iterations synchronous and the rest async.
  30874. * @param iterations total number of iterations
  30875. * @param syncedIterations number of synchronous iterations in each async iteration.
  30876. * @param fn the function to call each iteration.
  30877. * @param callback a success call back that will be called when iterating stops.
  30878. * @param breakFunction a break condition (optional)
  30879. * @param timeout timeout settings for the setTimeout function. default - 0.
  30880. * @returns the created async loop object
  30881. */
  30882. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  30883. }
  30884. }
  30885. declare module BABYLON {
  30886. /** @hidden */
  30887. export interface ICollisionCoordinator {
  30888. createCollider(): Collider;
  30889. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30890. init(scene: Scene): void;
  30891. }
  30892. /** @hidden */
  30893. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  30894. private _scene;
  30895. private _scaledPosition;
  30896. private _scaledVelocity;
  30897. private _finalPosition;
  30898. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30899. createCollider(): Collider;
  30900. init(scene: Scene): void;
  30901. private _collideWithWorld;
  30902. }
  30903. }
  30904. declare module BABYLON {
  30905. /**
  30906. * This class defines the direct association between an animation and a target
  30907. */
  30908. export class TargetedAnimation {
  30909. /**
  30910. * Animation to perform
  30911. */
  30912. animation: Animation;
  30913. /**
  30914. * Target to animate
  30915. */
  30916. target: any;
  30917. }
  30918. /**
  30919. * Use this class to create coordinated animations on multiple targets
  30920. */
  30921. export class AnimationGroup implements IDisposable {
  30922. /** The name of the animation group */
  30923. name: string;
  30924. private _scene;
  30925. private _targetedAnimations;
  30926. private _animatables;
  30927. private _from;
  30928. private _to;
  30929. private _isStarted;
  30930. private _isPaused;
  30931. private _speedRatio;
  30932. /**
  30933. * Gets or sets the unique id of the node
  30934. */
  30935. uniqueId: number;
  30936. /**
  30937. * This observable will notify when one animation have ended
  30938. */
  30939. onAnimationEndObservable: Observable<TargetedAnimation>;
  30940. /**
  30941. * Observer raised when one animation loops
  30942. */
  30943. onAnimationLoopObservable: Observable<TargetedAnimation>;
  30944. /**
  30945. * This observable will notify when all animations have ended.
  30946. */
  30947. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  30948. /**
  30949. * This observable will notify when all animations have paused.
  30950. */
  30951. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  30952. /**
  30953. * This observable will notify when all animations are playing.
  30954. */
  30955. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  30956. /**
  30957. * Gets the first frame
  30958. */
  30959. readonly from: number;
  30960. /**
  30961. * Gets the last frame
  30962. */
  30963. readonly to: number;
  30964. /**
  30965. * Define if the animations are started
  30966. */
  30967. readonly isStarted: boolean;
  30968. /**
  30969. * Gets a value indicating that the current group is playing
  30970. */
  30971. readonly isPlaying: boolean;
  30972. /**
  30973. * Gets or sets the speed ratio to use for all animations
  30974. */
  30975. /**
  30976. * Gets or sets the speed ratio to use for all animations
  30977. */
  30978. speedRatio: number;
  30979. /**
  30980. * Gets the targeted animations for this animation group
  30981. */
  30982. readonly targetedAnimations: Array<TargetedAnimation>;
  30983. /**
  30984. * returning the list of animatables controlled by this animation group.
  30985. */
  30986. readonly animatables: Array<Animatable>;
  30987. /**
  30988. * Instantiates a new Animation Group.
  30989. * This helps managing several animations at once.
  30990. * @see http://doc.babylonjs.com/how_to/group
  30991. * @param name Defines the name of the group
  30992. * @param scene Defines the scene the group belongs to
  30993. */
  30994. constructor(
  30995. /** The name of the animation group */
  30996. name: string, scene?: Nullable<Scene>);
  30997. /**
  30998. * Add an animation (with its target) in the group
  30999. * @param animation defines the animation we want to add
  31000. * @param target defines the target of the animation
  31001. * @returns the TargetedAnimation object
  31002. */
  31003. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31004. /**
  31005. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31006. * It can add constant keys at begin or end
  31007. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31008. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31009. * @returns the animation group
  31010. */
  31011. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31012. /**
  31013. * Start all animations on given targets
  31014. * @param loop defines if animations must loop
  31015. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31016. * @param from defines the from key (optional)
  31017. * @param to defines the to key (optional)
  31018. * @returns the current animation group
  31019. */
  31020. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31021. /**
  31022. * Pause all animations
  31023. * @returns the animation group
  31024. */
  31025. pause(): AnimationGroup;
  31026. /**
  31027. * Play all animations to initial state
  31028. * This function will start() the animations if they were not started or will restart() them if they were paused
  31029. * @param loop defines if animations must loop
  31030. * @returns the animation group
  31031. */
  31032. play(loop?: boolean): AnimationGroup;
  31033. /**
  31034. * Reset all animations to initial state
  31035. * @returns the animation group
  31036. */
  31037. reset(): AnimationGroup;
  31038. /**
  31039. * Restart animations from key 0
  31040. * @returns the animation group
  31041. */
  31042. restart(): AnimationGroup;
  31043. /**
  31044. * Stop all animations
  31045. * @returns the animation group
  31046. */
  31047. stop(): AnimationGroup;
  31048. /**
  31049. * Set animation weight for all animatables
  31050. * @param weight defines the weight to use
  31051. * @return the animationGroup
  31052. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31053. */
  31054. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31055. /**
  31056. * Synchronize and normalize all animatables with a source animatable
  31057. * @param root defines the root animatable to synchronize with
  31058. * @return the animationGroup
  31059. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31060. */
  31061. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31062. /**
  31063. * Goes to a specific frame in this animation group
  31064. * @param frame the frame number to go to
  31065. * @return the animationGroup
  31066. */
  31067. goToFrame(frame: number): AnimationGroup;
  31068. /**
  31069. * Dispose all associated resources
  31070. */
  31071. dispose(): void;
  31072. private _checkAnimationGroupEnded;
  31073. /**
  31074. * Clone the current animation group and returns a copy
  31075. * @param newName defines the name of the new group
  31076. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31077. * @returns the new aniamtion group
  31078. */
  31079. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31080. /**
  31081. * Returns a new AnimationGroup object parsed from the source provided.
  31082. * @param parsedAnimationGroup defines the source
  31083. * @param scene defines the scene that will receive the animationGroup
  31084. * @returns a new AnimationGroup
  31085. */
  31086. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31087. /**
  31088. * Returns the string "AnimationGroup"
  31089. * @returns "AnimationGroup"
  31090. */
  31091. getClassName(): string;
  31092. /**
  31093. * Creates a detailled string about the object
  31094. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31095. * @returns a string representing the object
  31096. */
  31097. toString(fullDetails?: boolean): string;
  31098. }
  31099. }
  31100. declare module BABYLON {
  31101. /**
  31102. * Define an interface for all classes that will hold resources
  31103. */
  31104. export interface IDisposable {
  31105. /**
  31106. * Releases all held resources
  31107. */
  31108. dispose(): void;
  31109. }
  31110. /** Interface defining initialization parameters for Scene class */
  31111. export interface SceneOptions {
  31112. /**
  31113. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31114. * It will improve performance when the number of geometries becomes important.
  31115. */
  31116. useGeometryUniqueIdsMap?: boolean;
  31117. /**
  31118. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31119. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31120. */
  31121. useMaterialMeshMap?: boolean;
  31122. /**
  31123. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31124. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31125. */
  31126. useClonedMeshhMap?: boolean;
  31127. }
  31128. /**
  31129. * Represents a scene to be rendered by the engine.
  31130. * @see http://doc.babylonjs.com/features/scene
  31131. */
  31132. export class Scene extends AbstractScene implements IAnimatable {
  31133. private static _uniqueIdCounter;
  31134. /** The fog is deactivated */
  31135. static readonly FOGMODE_NONE: number;
  31136. /** The fog density is following an exponential function */
  31137. static readonly FOGMODE_EXP: number;
  31138. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31139. static readonly FOGMODE_EXP2: number;
  31140. /** The fog density is following a linear function. */
  31141. static readonly FOGMODE_LINEAR: number;
  31142. /**
  31143. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31144. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31145. */
  31146. static MinDeltaTime: number;
  31147. /**
  31148. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31149. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31150. */
  31151. static MaxDeltaTime: number;
  31152. /**
  31153. * Factory used to create the default material.
  31154. * @param name The name of the material to create
  31155. * @param scene The scene to create the material for
  31156. * @returns The default material
  31157. */
  31158. static DefaultMaterialFactory(scene: Scene): Material;
  31159. /**
  31160. * Factory used to create the a collision coordinator.
  31161. * @returns The collision coordinator
  31162. */
  31163. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31164. /** @hidden */ protected readonly _isScene: boolean;
  31165. /**
  31166. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31167. */
  31168. autoClear: boolean;
  31169. /**
  31170. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31171. */
  31172. autoClearDepthAndStencil: boolean;
  31173. /**
  31174. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31175. */
  31176. clearColor: Color4;
  31177. /**
  31178. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31179. */
  31180. ambientColor: Color3;
  31181. /**
  31182. * This is use to store the default BRDF lookup for PBR materials in your scene.
  31183. * It should only be one of the following (if not the default embedded one):
  31184. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  31185. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  31186. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  31187. * The material properties need to be setup according to the type of texture in use.
  31188. */
  31189. environmentBRDFTexture: BaseTexture;
  31190. /** @hidden */
  31191. protected _environmentTexture: Nullable<BaseTexture>;
  31192. /**
  31193. * Texture used in all pbr material as the reflection texture.
  31194. * As in the majority of the scene they are the same (exception for multi room and so on),
  31195. * this is easier to reference from here than from all the materials.
  31196. */
  31197. /**
  31198. * Texture used in all pbr material as the reflection texture.
  31199. * As in the majority of the scene they are the same (exception for multi room and so on),
  31200. * this is easier to set here than in all the materials.
  31201. */
  31202. environmentTexture: Nullable<BaseTexture>;
  31203. /** @hidden */
  31204. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31205. /**
  31206. * Default image processing configuration used either in the rendering
  31207. * Forward main pass or through the imageProcessingPostProcess if present.
  31208. * As in the majority of the scene they are the same (exception for multi camera),
  31209. * this is easier to reference from here than from all the materials and post process.
  31210. *
  31211. * No setter as we it is a shared configuration, you can set the values instead.
  31212. */
  31213. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31214. private _forceWireframe;
  31215. /**
  31216. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31217. */
  31218. forceWireframe: boolean;
  31219. private _forcePointsCloud;
  31220. /**
  31221. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31222. */
  31223. forcePointsCloud: boolean;
  31224. /**
  31225. * Gets or sets the active clipplane 1
  31226. */
  31227. clipPlane: Nullable<Plane>;
  31228. /**
  31229. * Gets or sets the active clipplane 2
  31230. */
  31231. clipPlane2: Nullable<Plane>;
  31232. /**
  31233. * Gets or sets the active clipplane 3
  31234. */
  31235. clipPlane3: Nullable<Plane>;
  31236. /**
  31237. * Gets or sets the active clipplane 4
  31238. */
  31239. clipPlane4: Nullable<Plane>;
  31240. /**
  31241. * Gets or sets a boolean indicating if animations are enabled
  31242. */
  31243. animationsEnabled: boolean;
  31244. private _animationPropertiesOverride;
  31245. /**
  31246. * Gets or sets the animation properties override
  31247. */
  31248. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31249. /**
  31250. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31251. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31252. */
  31253. useConstantAnimationDeltaTime: boolean;
  31254. /**
  31255. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31256. * Please note that it requires to run a ray cast through the scene on every frame
  31257. */
  31258. constantlyUpdateMeshUnderPointer: boolean;
  31259. /**
  31260. * Defines the HTML cursor to use when hovering over interactive elements
  31261. */
  31262. hoverCursor: string;
  31263. /**
  31264. * Defines the HTML default cursor to use (empty by default)
  31265. */
  31266. defaultCursor: string;
  31267. /**
  31268. * This is used to call preventDefault() on pointer down
  31269. * in order to block unwanted artifacts like system double clicks
  31270. */
  31271. preventDefaultOnPointerDown: boolean;
  31272. /**
  31273. * This is used to call preventDefault() on pointer up
  31274. * in order to block unwanted artifacts like system double clicks
  31275. */
  31276. preventDefaultOnPointerUp: boolean;
  31277. /**
  31278. * Gets or sets user defined metadata
  31279. */
  31280. metadata: any;
  31281. /**
  31282. * For internal use only. Please do not use.
  31283. */
  31284. reservedDataStore: any;
  31285. /**
  31286. * Gets the name of the plugin used to load this scene (null by default)
  31287. */
  31288. loadingPluginName: string;
  31289. /**
  31290. * Use this array to add regular expressions used to disable offline support for specific urls
  31291. */
  31292. disableOfflineSupportExceptionRules: RegExp[];
  31293. /**
  31294. * An event triggered when the scene is disposed.
  31295. */
  31296. onDisposeObservable: Observable<Scene>;
  31297. private _onDisposeObserver;
  31298. /** Sets a function to be executed when this scene is disposed. */
  31299. onDispose: () => void;
  31300. /**
  31301. * An event triggered before rendering the scene (right after animations and physics)
  31302. */
  31303. onBeforeRenderObservable: Observable<Scene>;
  31304. private _onBeforeRenderObserver;
  31305. /** Sets a function to be executed before rendering this scene */
  31306. beforeRender: Nullable<() => void>;
  31307. /**
  31308. * An event triggered after rendering the scene
  31309. */
  31310. onAfterRenderObservable: Observable<Scene>;
  31311. private _onAfterRenderObserver;
  31312. /** Sets a function to be executed after rendering this scene */
  31313. afterRender: Nullable<() => void>;
  31314. /**
  31315. * An event triggered before animating the scene
  31316. */
  31317. onBeforeAnimationsObservable: Observable<Scene>;
  31318. /**
  31319. * An event triggered after animations processing
  31320. */
  31321. onAfterAnimationsObservable: Observable<Scene>;
  31322. /**
  31323. * An event triggered before draw calls are ready to be sent
  31324. */
  31325. onBeforeDrawPhaseObservable: Observable<Scene>;
  31326. /**
  31327. * An event triggered after draw calls have been sent
  31328. */
  31329. onAfterDrawPhaseObservable: Observable<Scene>;
  31330. /**
  31331. * An event triggered when the scene is ready
  31332. */
  31333. onReadyObservable: Observable<Scene>;
  31334. /**
  31335. * An event triggered before rendering a camera
  31336. */
  31337. onBeforeCameraRenderObservable: Observable<Camera>;
  31338. private _onBeforeCameraRenderObserver;
  31339. /** Sets a function to be executed before rendering a camera*/
  31340. beforeCameraRender: () => void;
  31341. /**
  31342. * An event triggered after rendering a camera
  31343. */
  31344. onAfterCameraRenderObservable: Observable<Camera>;
  31345. private _onAfterCameraRenderObserver;
  31346. /** Sets a function to be executed after rendering a camera*/
  31347. afterCameraRender: () => void;
  31348. /**
  31349. * An event triggered when active meshes evaluation is about to start
  31350. */
  31351. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31352. /**
  31353. * An event triggered when active meshes evaluation is done
  31354. */
  31355. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31356. /**
  31357. * An event triggered when particles rendering is about to start
  31358. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31359. */
  31360. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31361. /**
  31362. * An event triggered when particles rendering is done
  31363. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31364. */
  31365. onAfterParticlesRenderingObservable: Observable<Scene>;
  31366. /**
  31367. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31368. */
  31369. onDataLoadedObservable: Observable<Scene>;
  31370. /**
  31371. * An event triggered when a camera is created
  31372. */
  31373. onNewCameraAddedObservable: Observable<Camera>;
  31374. /**
  31375. * An event triggered when a camera is removed
  31376. */
  31377. onCameraRemovedObservable: Observable<Camera>;
  31378. /**
  31379. * An event triggered when a light is created
  31380. */
  31381. onNewLightAddedObservable: Observable<Light>;
  31382. /**
  31383. * An event triggered when a light is removed
  31384. */
  31385. onLightRemovedObservable: Observable<Light>;
  31386. /**
  31387. * An event triggered when a geometry is created
  31388. */
  31389. onNewGeometryAddedObservable: Observable<Geometry>;
  31390. /**
  31391. * An event triggered when a geometry is removed
  31392. */
  31393. onGeometryRemovedObservable: Observable<Geometry>;
  31394. /**
  31395. * An event triggered when a transform node is created
  31396. */
  31397. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31398. /**
  31399. * An event triggered when a transform node is removed
  31400. */
  31401. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31402. /**
  31403. * An event triggered when a mesh is created
  31404. */
  31405. onNewMeshAddedObservable: Observable<AbstractMesh>;
  31406. /**
  31407. * An event triggered when a mesh is removed
  31408. */
  31409. onMeshRemovedObservable: Observable<AbstractMesh>;
  31410. /**
  31411. * An event triggered when a skeleton is created
  31412. */
  31413. onNewSkeletonAddedObservable: Observable<Skeleton>;
  31414. /**
  31415. * An event triggered when a skeleton is removed
  31416. */
  31417. onSkeletonRemovedObservable: Observable<Skeleton>;
  31418. /**
  31419. * An event triggered when a material is created
  31420. */
  31421. onNewMaterialAddedObservable: Observable<Material>;
  31422. /**
  31423. * An event triggered when a material is removed
  31424. */
  31425. onMaterialRemovedObservable: Observable<Material>;
  31426. /**
  31427. * An event triggered when a texture is created
  31428. */
  31429. onNewTextureAddedObservable: Observable<BaseTexture>;
  31430. /**
  31431. * An event triggered when a texture is removed
  31432. */
  31433. onTextureRemovedObservable: Observable<BaseTexture>;
  31434. /**
  31435. * An event triggered when render targets are about to be rendered
  31436. * Can happen multiple times per frame.
  31437. */
  31438. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  31439. /**
  31440. * An event triggered when render targets were rendered.
  31441. * Can happen multiple times per frame.
  31442. */
  31443. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  31444. /**
  31445. * An event triggered before calculating deterministic simulation step
  31446. */
  31447. onBeforeStepObservable: Observable<Scene>;
  31448. /**
  31449. * An event triggered after calculating deterministic simulation step
  31450. */
  31451. onAfterStepObservable: Observable<Scene>;
  31452. /**
  31453. * An event triggered when the activeCamera property is updated
  31454. */
  31455. onActiveCameraChanged: Observable<Scene>;
  31456. /**
  31457. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  31458. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31459. * 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)
  31460. */
  31461. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31462. /**
  31463. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  31464. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31465. * 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)
  31466. */
  31467. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31468. /**
  31469. * This Observable will when a mesh has been imported into the scene.
  31470. */
  31471. onMeshImportedObservable: Observable<AbstractMesh>;
  31472. /**
  31473. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  31474. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  31475. */
  31476. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  31477. /** @hidden */ registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  31478. /**
  31479. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  31480. */
  31481. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  31482. /**
  31483. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  31484. */
  31485. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  31486. /**
  31487. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  31488. */
  31489. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  31490. private _onPointerMove;
  31491. private _onPointerDown;
  31492. private _onPointerUp;
  31493. /** Callback called when a pointer move is detected */
  31494. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31495. /** Callback called when a pointer down is detected */
  31496. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31497. /** Callback called when a pointer up is detected */
  31498. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  31499. /** Callback called when a pointer pick is detected */
  31500. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  31501. /**
  31502. * 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).
  31503. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  31504. */
  31505. onPrePointerObservable: Observable<PointerInfoPre>;
  31506. /**
  31507. * Observable event triggered each time an input event is received from the rendering canvas
  31508. */
  31509. onPointerObservable: Observable<PointerInfo>;
  31510. /**
  31511. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  31512. */
  31513. readonly unTranslatedPointer: Vector2;
  31514. /** The distance in pixel that you have to move to prevent some events */
  31515. static DragMovementThreshold: number;
  31516. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31517. static LongPressDelay: number;
  31518. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31519. static DoubleClickDelay: number;
  31520. /** If you need to check double click without raising a single click at first click, enable this flag */
  31521. static ExclusiveDoubleClickMode: boolean;
  31522. private _initClickEvent;
  31523. private _initActionManager;
  31524. private _delayedSimpleClick;
  31525. private _delayedSimpleClickTimeout;
  31526. private _previousDelayedSimpleClickTimeout;
  31527. private _meshPickProceed;
  31528. private _previousButtonPressed;
  31529. private _currentPickResult;
  31530. private _previousPickResult;
  31531. private _totalPointersPressed;
  31532. private _doubleClickOccured;
  31533. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  31534. cameraToUseForPointers: Nullable<Camera>;
  31535. private _pointerX;
  31536. private _pointerY;
  31537. private _unTranslatedPointerX;
  31538. private _unTranslatedPointerY;
  31539. private _startingPointerPosition;
  31540. private _previousStartingPointerPosition;
  31541. private _startingPointerTime;
  31542. private _previousStartingPointerTime;
  31543. private _pointerCaptures;
  31544. private _timeAccumulator;
  31545. private _currentStepId;
  31546. private _currentInternalStep;
  31547. /** @hidden */ mirroredCameraPosition: Nullable<Vector3>;
  31548. /**
  31549. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  31550. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  31551. */
  31552. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  31553. /**
  31554. * Observable event triggered each time an keyboard event is received from the hosting window
  31555. */
  31556. onKeyboardObservable: Observable<KeyboardInfo>;
  31557. private _onKeyDown;
  31558. private _onKeyUp;
  31559. private _onCanvasFocusObserver;
  31560. private _onCanvasBlurObserver;
  31561. private _useRightHandedSystem;
  31562. /**
  31563. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  31564. */
  31565. useRightHandedSystem: boolean;
  31566. /**
  31567. * Sets the step Id used by deterministic lock step
  31568. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31569. * @param newStepId defines the step Id
  31570. */
  31571. setStepId(newStepId: number): void;
  31572. /**
  31573. * Gets the step Id used by deterministic lock step
  31574. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31575. * @returns the step Id
  31576. */
  31577. getStepId(): number;
  31578. /**
  31579. * Gets the internal step used by deterministic lock step
  31580. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31581. * @returns the internal step
  31582. */
  31583. getInternalStep(): number;
  31584. private _fogEnabled;
  31585. /**
  31586. * Gets or sets a boolean indicating if fog is enabled on this scene
  31587. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31588. * (Default is true)
  31589. */
  31590. fogEnabled: boolean;
  31591. private _fogMode;
  31592. /**
  31593. * Gets or sets the fog mode to use
  31594. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31595. * | mode | value |
  31596. * | --- | --- |
  31597. * | FOGMODE_NONE | 0 |
  31598. * | FOGMODE_EXP | 1 |
  31599. * | FOGMODE_EXP2 | 2 |
  31600. * | FOGMODE_LINEAR | 3 |
  31601. */
  31602. fogMode: number;
  31603. /**
  31604. * Gets or sets the fog color to use
  31605. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31606. * (Default is Color3(0.2, 0.2, 0.3))
  31607. */
  31608. fogColor: Color3;
  31609. /**
  31610. * Gets or sets the fog density to use
  31611. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31612. * (Default is 0.1)
  31613. */
  31614. fogDensity: number;
  31615. /**
  31616. * Gets or sets the fog start distance to use
  31617. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31618. * (Default is 0)
  31619. */
  31620. fogStart: number;
  31621. /**
  31622. * Gets or sets the fog end distance to use
  31623. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31624. * (Default is 1000)
  31625. */
  31626. fogEnd: number;
  31627. private _shadowsEnabled;
  31628. /**
  31629. * Gets or sets a boolean indicating if shadows are enabled on this scene
  31630. */
  31631. shadowsEnabled: boolean;
  31632. private _lightsEnabled;
  31633. /**
  31634. * Gets or sets a boolean indicating if lights are enabled on this scene
  31635. */
  31636. lightsEnabled: boolean;
  31637. /** All of the active cameras added to this scene. */
  31638. activeCameras: Camera[];
  31639. /** @hidden */ activeCamera: Nullable<Camera>;
  31640. /** Gets or sets the current active camera */
  31641. activeCamera: Nullable<Camera>;
  31642. private _defaultMaterial;
  31643. /** The default material used on meshes when no material is affected */
  31644. /** The default material used on meshes when no material is affected */
  31645. defaultMaterial: Material;
  31646. private _texturesEnabled;
  31647. /**
  31648. * Gets or sets a boolean indicating if textures are enabled on this scene
  31649. */
  31650. texturesEnabled: boolean;
  31651. /**
  31652. * Gets or sets a boolean indicating if particles are enabled on this scene
  31653. */
  31654. particlesEnabled: boolean;
  31655. /**
  31656. * Gets or sets a boolean indicating if sprites are enabled on this scene
  31657. */
  31658. spritesEnabled: boolean;
  31659. private _skeletonsEnabled;
  31660. /**
  31661. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  31662. */
  31663. skeletonsEnabled: boolean;
  31664. /**
  31665. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  31666. */
  31667. lensFlaresEnabled: boolean;
  31668. /**
  31669. * Gets or sets a boolean indicating if collisions are enabled on this scene
  31670. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31671. */
  31672. collisionsEnabled: boolean;
  31673. private _collisionCoordinator;
  31674. /** @hidden */
  31675. readonly collisionCoordinator: ICollisionCoordinator;
  31676. /**
  31677. * Defines the gravity applied to this scene (used only for collisions)
  31678. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31679. */
  31680. gravity: Vector3;
  31681. /**
  31682. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  31683. */
  31684. postProcessesEnabled: boolean;
  31685. /**
  31686. * The list of postprocesses added to the scene
  31687. */
  31688. postProcesses: PostProcess[];
  31689. /**
  31690. * Gets the current postprocess manager
  31691. */
  31692. postProcessManager: PostProcessManager;
  31693. /**
  31694. * Gets or sets a boolean indicating if render targets are enabled on this scene
  31695. */
  31696. renderTargetsEnabled: boolean;
  31697. /**
  31698. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  31699. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  31700. */
  31701. dumpNextRenderTargets: boolean;
  31702. /**
  31703. * The list of user defined render targets added to the scene
  31704. */
  31705. customRenderTargets: RenderTargetTexture[];
  31706. /**
  31707. * Defines if texture loading must be delayed
  31708. * If true, textures will only be loaded when they need to be rendered
  31709. */
  31710. useDelayedTextureLoading: boolean;
  31711. /**
  31712. * Gets the list of meshes imported to the scene through SceneLoader
  31713. */
  31714. importedMeshesFiles: String[];
  31715. /**
  31716. * Gets or sets a boolean indicating if probes are enabled on this scene
  31717. */
  31718. probesEnabled: boolean;
  31719. /**
  31720. * Gets or sets the current offline provider to use to store scene data
  31721. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  31722. */
  31723. offlineProvider: IOfflineProvider;
  31724. /**
  31725. * Gets or sets the action manager associated with the scene
  31726. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31727. */
  31728. actionManager: AbstractActionManager;
  31729. private _meshesForIntersections;
  31730. /**
  31731. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  31732. */
  31733. proceduralTexturesEnabled: boolean;
  31734. private _engine;
  31735. private _totalVertices;
  31736. /** @hidden */ activeIndices: PerfCounter;
  31737. /** @hidden */ activeParticles: PerfCounter;
  31738. /** @hidden */ activeBones: PerfCounter;
  31739. private _animationRatio;
  31740. /** @hidden */ animationTimeLast: number;
  31741. /** @hidden */ animationTime: number;
  31742. /**
  31743. * Gets or sets a general scale for animation speed
  31744. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  31745. */
  31746. animationTimeScale: number;
  31747. /** @hidden */ cachedMaterial: Nullable<Material>;
  31748. /** @hidden */ cachedEffect: Nullable<Effect>;
  31749. /** @hidden */ cachedVisibility: Nullable<number>;
  31750. private _renderId;
  31751. private _frameId;
  31752. private _executeWhenReadyTimeoutId;
  31753. private _intermediateRendering;
  31754. private _viewUpdateFlag;
  31755. private _projectionUpdateFlag;
  31756. /** @hidden */ toBeDisposed: Nullable<IDisposable>[];
  31757. private _activeRequests;
  31758. /** @hidden */ pendingData: any[];
  31759. private _isDisposed;
  31760. /**
  31761. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  31762. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  31763. */
  31764. dispatchAllSubMeshesOfActiveMeshes: boolean;
  31765. private _activeMeshes;
  31766. private _processedMaterials;
  31767. private _renderTargets;
  31768. /** @hidden */ activeParticleSystems: SmartArray<IParticleSystem>;
  31769. private _activeSkeletons;
  31770. private _softwareSkinnedMeshes;
  31771. private _renderingManager;
  31772. /** @hidden */ activeAnimatables: Animatable[];
  31773. private _transformMatrix;
  31774. private _sceneUbo;
  31775. /** @hidden */ viewMatrix: Matrix;
  31776. private _projectionMatrix;
  31777. private _wheelEventName;
  31778. /** @hidden */ forcedViewPosition: Nullable<Vector3>;
  31779. /** @hidden */ frustumPlanes: Plane[];
  31780. /**
  31781. * Gets the list of frustum planes (built from the active camera)
  31782. */
  31783. readonly frustumPlanes: Plane[];
  31784. /**
  31785. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  31786. * This is useful if there are more lights that the maximum simulteanous authorized
  31787. */
  31788. requireLightSorting: boolean;
  31789. /** @hidden */
  31790. readonly useMaterialMeshMap: boolean;
  31791. /** @hidden */
  31792. readonly useClonedMeshhMap: boolean;
  31793. private _pointerOverMesh;
  31794. private _pickedDownMesh;
  31795. private _pickedUpMesh;
  31796. private _externalData;
  31797. private _uid;
  31798. /**
  31799. * @hidden
  31800. * Backing store of defined scene components.
  31801. */ components: ISceneComponent[];
  31802. /**
  31803. * @hidden
  31804. * Backing store of defined scene components.
  31805. */ serializableComponents: ISceneSerializableComponent[];
  31806. /**
  31807. * List of components to register on the next registration step.
  31808. */
  31809. private _transientComponents;
  31810. /**
  31811. * Registers the transient components if needed.
  31812. */
  31813. private _registerTransientComponents;
  31814. /**
  31815. * @hidden
  31816. * Add a component to the scene.
  31817. * Note that the ccomponent could be registered on th next frame if this is called after
  31818. * the register component stage.
  31819. * @param component Defines the component to add to the scene
  31820. */ addComponent(component: ISceneComponent): void;
  31821. /**
  31822. * @hidden
  31823. * Gets a component from the scene.
  31824. * @param name defines the name of the component to retrieve
  31825. * @returns the component or null if not present
  31826. */ getComponent(name: string): Nullable<ISceneComponent>;
  31827. /**
  31828. * @hidden
  31829. * Defines the actions happening before camera updates.
  31830. */ beforeCameraUpdateStage: Stage<SimpleStageAction>;
  31831. /**
  31832. * @hidden
  31833. * Defines the actions happening before clear the canvas.
  31834. */ beforeClearStage: Stage<SimpleStageAction>;
  31835. /**
  31836. * @hidden
  31837. * Defines the actions when collecting render targets for the frame.
  31838. */ gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  31839. /**
  31840. * @hidden
  31841. * Defines the actions happening for one camera in the frame.
  31842. */ gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  31843. /**
  31844. * @hidden
  31845. * Defines the actions happening during the per mesh ready checks.
  31846. */ isReadyForMeshStage: Stage<MeshStageAction>;
  31847. /**
  31848. * @hidden
  31849. * Defines the actions happening before evaluate active mesh checks.
  31850. */ beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  31851. /**
  31852. * @hidden
  31853. * Defines the actions happening during the evaluate sub mesh checks.
  31854. */ evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  31855. /**
  31856. * @hidden
  31857. * Defines the actions happening during the active mesh stage.
  31858. */ activeMeshStage: Stage<ActiveMeshStageAction>;
  31859. /**
  31860. * @hidden
  31861. * Defines the actions happening during the per camera render target step.
  31862. */ cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  31863. /**
  31864. * @hidden
  31865. * Defines the actions happening just before the active camera is drawing.
  31866. */ beforeCameraDrawStage: Stage<CameraStageAction>;
  31867. /**
  31868. * @hidden
  31869. * Defines the actions happening just before a render target is drawing.
  31870. */ beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  31871. /**
  31872. * @hidden
  31873. * Defines the actions happening just before a rendering group is drawing.
  31874. */ beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  31875. /**
  31876. * @hidden
  31877. * Defines the actions happening just before a mesh is drawing.
  31878. */ beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  31879. /**
  31880. * @hidden
  31881. * Defines the actions happening just after a mesh has been drawn.
  31882. */ afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  31883. /**
  31884. * @hidden
  31885. * Defines the actions happening just after a rendering group has been drawn.
  31886. */ afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  31887. /**
  31888. * @hidden
  31889. * Defines the actions happening just after the active camera has been drawn.
  31890. */ afterCameraDrawStage: Stage<CameraStageAction>;
  31891. /**
  31892. * @hidden
  31893. * Defines the actions happening just after a render target has been drawn.
  31894. */ afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  31895. /**
  31896. * @hidden
  31897. * Defines the actions happening just after rendering all cameras and computing intersections.
  31898. */ afterRenderStage: Stage<SimpleStageAction>;
  31899. /**
  31900. * @hidden
  31901. * Defines the actions happening when a pointer move event happens.
  31902. */ pointerMoveStage: Stage<PointerMoveStageAction>;
  31903. /**
  31904. * @hidden
  31905. * Defines the actions happening when a pointer down event happens.
  31906. */ pointerDownStage: Stage<PointerUpDownStageAction>;
  31907. /**
  31908. * @hidden
  31909. * Defines the actions happening when a pointer up event happens.
  31910. */ pointerUpStage: Stage<PointerUpDownStageAction>;
  31911. /**
  31912. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  31913. */
  31914. private geometriesByUniqueId;
  31915. /**
  31916. * Creates a new Scene
  31917. * @param engine defines the engine to use to render this scene
  31918. * @param options defines the scene options
  31919. */
  31920. constructor(engine: Engine, options?: SceneOptions);
  31921. /**
  31922. * Gets a string idenfifying the name of the class
  31923. * @returns "Scene" string
  31924. */
  31925. getClassName(): string;
  31926. private _defaultMeshCandidates;
  31927. /**
  31928. * @hidden
  31929. */ getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  31930. private _defaultSubMeshCandidates;
  31931. /**
  31932. * @hidden
  31933. */ getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  31934. /**
  31935. * Sets the default candidate providers for the scene.
  31936. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  31937. * and getCollidingSubMeshCandidates to their default function
  31938. */
  31939. setDefaultCandidateProviders(): void;
  31940. /**
  31941. * Gets the mesh that is currently under the pointer
  31942. */
  31943. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31944. /**
  31945. * Gets or sets the current on-screen X position of the pointer
  31946. */
  31947. pointerX: number;
  31948. /**
  31949. * Gets or sets the current on-screen Y position of the pointer
  31950. */
  31951. pointerY: number;
  31952. /**
  31953. * Gets the cached material (ie. the latest rendered one)
  31954. * @returns the cached material
  31955. */
  31956. getCachedMaterial(): Nullable<Material>;
  31957. /**
  31958. * Gets the cached effect (ie. the latest rendered one)
  31959. * @returns the cached effect
  31960. */
  31961. getCachedEffect(): Nullable<Effect>;
  31962. /**
  31963. * Gets the cached visibility state (ie. the latest rendered one)
  31964. * @returns the cached visibility state
  31965. */
  31966. getCachedVisibility(): Nullable<number>;
  31967. /**
  31968. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  31969. * @param material defines the current material
  31970. * @param effect defines the current effect
  31971. * @param visibility defines the current visibility state
  31972. * @returns true if one parameter is not cached
  31973. */
  31974. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  31975. /**
  31976. * Gets the engine associated with the scene
  31977. * @returns an Engine
  31978. */
  31979. getEngine(): Engine;
  31980. /**
  31981. * Gets the total number of vertices rendered per frame
  31982. * @returns the total number of vertices rendered per frame
  31983. */
  31984. getTotalVertices(): number;
  31985. /**
  31986. * Gets the performance counter for total vertices
  31987. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31988. */
  31989. readonly totalVerticesPerfCounter: PerfCounter;
  31990. /**
  31991. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  31992. * @returns the total number of active indices rendered per frame
  31993. */
  31994. getActiveIndices(): number;
  31995. /**
  31996. * Gets the performance counter for active indices
  31997. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31998. */
  31999. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32000. /**
  32001. * Gets the total number of active particles rendered per frame
  32002. * @returns the total number of active particles rendered per frame
  32003. */
  32004. getActiveParticles(): number;
  32005. /**
  32006. * Gets the performance counter for active particles
  32007. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32008. */
  32009. readonly activeParticlesPerfCounter: PerfCounter;
  32010. /**
  32011. * Gets the total number of active bones rendered per frame
  32012. * @returns the total number of active bones rendered per frame
  32013. */
  32014. getActiveBones(): number;
  32015. /**
  32016. * Gets the performance counter for active bones
  32017. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32018. */
  32019. readonly activeBonesPerfCounter: PerfCounter;
  32020. /**
  32021. * Gets the array of active meshes
  32022. * @returns an array of AbstractMesh
  32023. */
  32024. getActiveMeshes(): SmartArray<AbstractMesh>;
  32025. /**
  32026. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32027. * @returns a number
  32028. */
  32029. getAnimationRatio(): number;
  32030. /**
  32031. * Gets an unique Id for the current render phase
  32032. * @returns a number
  32033. */
  32034. getRenderId(): number;
  32035. /**
  32036. * Gets an unique Id for the current frame
  32037. * @returns a number
  32038. */
  32039. getFrameId(): number;
  32040. /** Call this function if you want to manually increment the render Id*/
  32041. incrementRenderId(): void;
  32042. private _updatePointerPosition;
  32043. private _createUbo;
  32044. private _setRayOnPointerInfo;
  32045. /**
  32046. * Use this method to simulate a pointer move on a mesh
  32047. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32048. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32049. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32050. * @returns the current scene
  32051. */
  32052. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32053. private _processPointerMove;
  32054. private _checkPrePointerObservable;
  32055. /**
  32056. * Use this method to simulate a pointer down on a mesh
  32057. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32058. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32059. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32060. * @returns the current scene
  32061. */
  32062. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32063. private _processPointerDown;
  32064. /**
  32065. * Use this method to simulate a pointer up on a mesh
  32066. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32067. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32068. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32069. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32070. * @returns the current scene
  32071. */
  32072. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32073. private _processPointerUp;
  32074. /**
  32075. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32076. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32077. * @returns true if the pointer was captured
  32078. */
  32079. isPointerCaptured(pointerId?: number): boolean;
  32080. /** @hidden */ isPointerSwiping(): boolean;
  32081. /**
  32082. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32083. * @param attachUp defines if you want to attach events to pointerup
  32084. * @param attachDown defines if you want to attach events to pointerdown
  32085. * @param attachMove defines if you want to attach events to pointermove
  32086. */
  32087. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32088. /** Detaches all event handlers*/
  32089. detachControl(): void;
  32090. /**
  32091. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32092. * Delay loaded resources are not taking in account
  32093. * @return true if all required resources are ready
  32094. */
  32095. isReady(): boolean;
  32096. /** Resets all cached information relative to material (including effect and visibility) */
  32097. resetCachedMaterial(): void;
  32098. /**
  32099. * Registers a function to be called before every frame render
  32100. * @param func defines the function to register
  32101. */
  32102. registerBeforeRender(func: () => void): void;
  32103. /**
  32104. * Unregisters a function called before every frame render
  32105. * @param func defines the function to unregister
  32106. */
  32107. unregisterBeforeRender(func: () => void): void;
  32108. /**
  32109. * Registers a function to be called after every frame render
  32110. * @param func defines the function to register
  32111. */
  32112. registerAfterRender(func: () => void): void;
  32113. /**
  32114. * Unregisters a function called after every frame render
  32115. * @param func defines the function to unregister
  32116. */
  32117. unregisterAfterRender(func: () => void): void;
  32118. private _executeOnceBeforeRender;
  32119. /**
  32120. * The provided function will run before render once and will be disposed afterwards.
  32121. * A timeout delay can be provided so that the function will be executed in N ms.
  32122. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32123. * @param func The function to be executed.
  32124. * @param timeout optional delay in ms
  32125. */
  32126. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32127. /** @hidden */ addPendingData(data: any): void;
  32128. /** @hidden */ removePendingData(data: any): void;
  32129. /**
  32130. * Returns the number of items waiting to be loaded
  32131. * @returns the number of items waiting to be loaded
  32132. */
  32133. getWaitingItemsCount(): number;
  32134. /**
  32135. * Returns a boolean indicating if the scene is still loading data
  32136. */
  32137. readonly isLoading: boolean;
  32138. /**
  32139. * Registers a function to be executed when the scene is ready
  32140. * @param {Function} func - the function to be executed
  32141. */
  32142. executeWhenReady(func: () => void): void;
  32143. /**
  32144. * Returns a promise that resolves when the scene is ready
  32145. * @returns A promise that resolves when the scene is ready
  32146. */
  32147. whenReadyAsync(): Promise<void>;
  32148. /** @hidden */ checkIsReady(): void;
  32149. /**
  32150. * Gets all animatable attached to the scene
  32151. */
  32152. readonly animatables: Animatable[];
  32153. /**
  32154. * Resets the last animation time frame.
  32155. * Useful to override when animations start running when loading a scene for the first time.
  32156. */
  32157. resetLastAnimationTimeFrame(): void;
  32158. /**
  32159. * Gets the current view matrix
  32160. * @returns a Matrix
  32161. */
  32162. getViewMatrix(): Matrix;
  32163. /**
  32164. * Gets the current projection matrix
  32165. * @returns a Matrix
  32166. */
  32167. getProjectionMatrix(): Matrix;
  32168. /**
  32169. * Gets the current transform matrix
  32170. * @returns a Matrix made of View * Projection
  32171. */
  32172. getTransformMatrix(): Matrix;
  32173. /**
  32174. * Sets the current transform matrix
  32175. * @param viewL defines the View matrix to use
  32176. * @param projectionL defines the Projection matrix to use
  32177. * @param viewR defines the right View matrix to use (if provided)
  32178. * @param projectionR defines the right Projection matrix to use (if provided)
  32179. */
  32180. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  32181. /**
  32182. * Gets the uniform buffer used to store scene data
  32183. * @returns a UniformBuffer
  32184. */
  32185. getSceneUniformBuffer(): UniformBuffer;
  32186. /**
  32187. * Gets an unique (relatively to the current scene) Id
  32188. * @returns an unique number for the scene
  32189. */
  32190. getUniqueId(): number;
  32191. /**
  32192. * Add a mesh to the list of scene's meshes
  32193. * @param newMesh defines the mesh to add
  32194. * @param recursive if all child meshes should also be added to the scene
  32195. */
  32196. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32197. /**
  32198. * Remove a mesh for the list of scene's meshes
  32199. * @param toRemove defines the mesh to remove
  32200. * @param recursive if all child meshes should also be removed from the scene
  32201. * @returns the index where the mesh was in the mesh list
  32202. */
  32203. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32204. /**
  32205. * Add a transform node to the list of scene's transform nodes
  32206. * @param newTransformNode defines the transform node to add
  32207. */
  32208. addTransformNode(newTransformNode: TransformNode): void;
  32209. /**
  32210. * Remove a transform node for the list of scene's transform nodes
  32211. * @param toRemove defines the transform node to remove
  32212. * @returns the index where the transform node was in the transform node list
  32213. */
  32214. removeTransformNode(toRemove: TransformNode): number;
  32215. /**
  32216. * Remove a skeleton for the list of scene's skeletons
  32217. * @param toRemove defines the skeleton to remove
  32218. * @returns the index where the skeleton was in the skeleton list
  32219. */
  32220. removeSkeleton(toRemove: Skeleton): number;
  32221. /**
  32222. * Remove a morph target for the list of scene's morph targets
  32223. * @param toRemove defines the morph target to remove
  32224. * @returns the index where the morph target was in the morph target list
  32225. */
  32226. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32227. /**
  32228. * Remove a light for the list of scene's lights
  32229. * @param toRemove defines the light to remove
  32230. * @returns the index where the light was in the light list
  32231. */
  32232. removeLight(toRemove: Light): number;
  32233. /**
  32234. * Remove a camera for the list of scene's cameras
  32235. * @param toRemove defines the camera to remove
  32236. * @returns the index where the camera was in the camera list
  32237. */
  32238. removeCamera(toRemove: Camera): number;
  32239. /**
  32240. * Remove a particle system for the list of scene's particle systems
  32241. * @param toRemove defines the particle system to remove
  32242. * @returns the index where the particle system was in the particle system list
  32243. */
  32244. removeParticleSystem(toRemove: IParticleSystem): number;
  32245. /**
  32246. * Remove a animation for the list of scene's animations
  32247. * @param toRemove defines the animation to remove
  32248. * @returns the index where the animation was in the animation list
  32249. */
  32250. removeAnimation(toRemove: Animation): number;
  32251. /**
  32252. * Removes the given animation group from this scene.
  32253. * @param toRemove The animation group to remove
  32254. * @returns The index of the removed animation group
  32255. */
  32256. removeAnimationGroup(toRemove: AnimationGroup): number;
  32257. /**
  32258. * Removes the given multi-material from this scene.
  32259. * @param toRemove The multi-material to remove
  32260. * @returns The index of the removed multi-material
  32261. */
  32262. removeMultiMaterial(toRemove: MultiMaterial): number;
  32263. /**
  32264. * Removes the given material from this scene.
  32265. * @param toRemove The material to remove
  32266. * @returns The index of the removed material
  32267. */
  32268. removeMaterial(toRemove: Material): number;
  32269. /**
  32270. * Removes the given action manager from this scene.
  32271. * @param toRemove The action manager to remove
  32272. * @returns The index of the removed action manager
  32273. */
  32274. removeActionManager(toRemove: AbstractActionManager): number;
  32275. /**
  32276. * Removes the given texture from this scene.
  32277. * @param toRemove The texture to remove
  32278. * @returns The index of the removed texture
  32279. */
  32280. removeTexture(toRemove: BaseTexture): number;
  32281. /**
  32282. * Adds the given light to this scene
  32283. * @param newLight The light to add
  32284. */
  32285. addLight(newLight: Light): void;
  32286. /**
  32287. * Sorts the list list based on light priorities
  32288. */
  32289. sortLightsByPriority(): void;
  32290. /**
  32291. * Adds the given camera to this scene
  32292. * @param newCamera The camera to add
  32293. */
  32294. addCamera(newCamera: Camera): void;
  32295. /**
  32296. * Adds the given skeleton to this scene
  32297. * @param newSkeleton The skeleton to add
  32298. */
  32299. addSkeleton(newSkeleton: Skeleton): void;
  32300. /**
  32301. * Adds the given particle system to this scene
  32302. * @param newParticleSystem The particle system to add
  32303. */
  32304. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32305. /**
  32306. * Adds the given animation to this scene
  32307. * @param newAnimation The animation to add
  32308. */
  32309. addAnimation(newAnimation: Animation): void;
  32310. /**
  32311. * Adds the given animation group to this scene.
  32312. * @param newAnimationGroup The animation group to add
  32313. */
  32314. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32315. /**
  32316. * Adds the given multi-material to this scene
  32317. * @param newMultiMaterial The multi-material to add
  32318. */
  32319. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32320. /**
  32321. * Adds the given material to this scene
  32322. * @param newMaterial The material to add
  32323. */
  32324. addMaterial(newMaterial: Material): void;
  32325. /**
  32326. * Adds the given morph target to this scene
  32327. * @param newMorphTargetManager The morph target to add
  32328. */
  32329. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32330. /**
  32331. * Adds the given geometry to this scene
  32332. * @param newGeometry The geometry to add
  32333. */
  32334. addGeometry(newGeometry: Geometry): void;
  32335. /**
  32336. * Adds the given action manager to this scene
  32337. * @param newActionManager The action manager to add
  32338. */
  32339. addActionManager(newActionManager: AbstractActionManager): void;
  32340. /**
  32341. * Adds the given texture to this scene.
  32342. * @param newTexture The texture to add
  32343. */
  32344. addTexture(newTexture: BaseTexture): void;
  32345. /**
  32346. * Switch active camera
  32347. * @param newCamera defines the new active camera
  32348. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32349. */
  32350. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32351. /**
  32352. * sets the active camera of the scene using its ID
  32353. * @param id defines the camera's ID
  32354. * @return the new active camera or null if none found.
  32355. */
  32356. setActiveCameraByID(id: string): Nullable<Camera>;
  32357. /**
  32358. * sets the active camera of the scene using its name
  32359. * @param name defines the camera's name
  32360. * @returns the new active camera or null if none found.
  32361. */
  32362. setActiveCameraByName(name: string): Nullable<Camera>;
  32363. /**
  32364. * get an animation group using its name
  32365. * @param name defines the material's name
  32366. * @return the animation group or null if none found.
  32367. */
  32368. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  32369. /**
  32370. * Get a material using its unique id
  32371. * @param uniqueId defines the material's unique id
  32372. * @return the material or null if none found.
  32373. */
  32374. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  32375. /**
  32376. * get a material using its id
  32377. * @param id defines the material's ID
  32378. * @return the material or null if none found.
  32379. */
  32380. getMaterialByID(id: string): Nullable<Material>;
  32381. /**
  32382. * Gets a material using its name
  32383. * @param name defines the material's name
  32384. * @return the material or null if none found.
  32385. */
  32386. getMaterialByName(name: string): Nullable<Material>;
  32387. /**
  32388. * Gets a camera using its id
  32389. * @param id defines the id to look for
  32390. * @returns the camera or null if not found
  32391. */
  32392. getCameraByID(id: string): Nullable<Camera>;
  32393. /**
  32394. * Gets a camera using its unique id
  32395. * @param uniqueId defines the unique id to look for
  32396. * @returns the camera or null if not found
  32397. */
  32398. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  32399. /**
  32400. * Gets a camera using its name
  32401. * @param name defines the camera's name
  32402. * @return the camera or null if none found.
  32403. */
  32404. getCameraByName(name: string): Nullable<Camera>;
  32405. /**
  32406. * Gets a bone using its id
  32407. * @param id defines the bone's id
  32408. * @return the bone or null if not found
  32409. */
  32410. getBoneByID(id: string): Nullable<Bone>;
  32411. /**
  32412. * Gets a bone using its id
  32413. * @param name defines the bone's name
  32414. * @return the bone or null if not found
  32415. */
  32416. getBoneByName(name: string): Nullable<Bone>;
  32417. /**
  32418. * Gets a light node using its name
  32419. * @param name defines the the light's name
  32420. * @return the light or null if none found.
  32421. */
  32422. getLightByName(name: string): Nullable<Light>;
  32423. /**
  32424. * Gets a light node using its id
  32425. * @param id defines the light's id
  32426. * @return the light or null if none found.
  32427. */
  32428. getLightByID(id: string): Nullable<Light>;
  32429. /**
  32430. * Gets a light node using its scene-generated unique ID
  32431. * @param uniqueId defines the light's unique id
  32432. * @return the light or null if none found.
  32433. */
  32434. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  32435. /**
  32436. * Gets a particle system by id
  32437. * @param id defines the particle system id
  32438. * @return the corresponding system or null if none found
  32439. */
  32440. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  32441. /**
  32442. * Gets a geometry using its ID
  32443. * @param id defines the geometry's id
  32444. * @return the geometry or null if none found.
  32445. */
  32446. getGeometryByID(id: string): Nullable<Geometry>;
  32447. private _getGeometryByUniqueID;
  32448. /**
  32449. * Add a new geometry to this scene
  32450. * @param geometry defines the geometry to be added to the scene.
  32451. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  32452. * @return a boolean defining if the geometry was added or not
  32453. */
  32454. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  32455. /**
  32456. * Removes an existing geometry
  32457. * @param geometry defines the geometry to be removed from the scene
  32458. * @return a boolean defining if the geometry was removed or not
  32459. */
  32460. removeGeometry(geometry: Geometry): boolean;
  32461. /**
  32462. * Gets the list of geometries attached to the scene
  32463. * @returns an array of Geometry
  32464. */
  32465. getGeometries(): Geometry[];
  32466. /**
  32467. * Gets the first added mesh found of a given ID
  32468. * @param id defines the id to search for
  32469. * @return the mesh found or null if not found at all
  32470. */
  32471. getMeshByID(id: string): Nullable<AbstractMesh>;
  32472. /**
  32473. * Gets a list of meshes using their id
  32474. * @param id defines the id to search for
  32475. * @returns a list of meshes
  32476. */
  32477. getMeshesByID(id: string): Array<AbstractMesh>;
  32478. /**
  32479. * Gets the first added transform node found of a given ID
  32480. * @param id defines the id to search for
  32481. * @return the found transform node or null if not found at all.
  32482. */
  32483. getTransformNodeByID(id: string): Nullable<TransformNode>;
  32484. /**
  32485. * Gets a transform node with its auto-generated unique id
  32486. * @param uniqueId efines the unique id to search for
  32487. * @return the found transform node or null if not found at all.
  32488. */
  32489. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  32490. /**
  32491. * Gets a list of transform nodes using their id
  32492. * @param id defines the id to search for
  32493. * @returns a list of transform nodes
  32494. */
  32495. getTransformNodesByID(id: string): Array<TransformNode>;
  32496. /**
  32497. * Gets a mesh with its auto-generated unique id
  32498. * @param uniqueId defines the unique id to search for
  32499. * @return the found mesh or null if not found at all.
  32500. */
  32501. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  32502. /**
  32503. * Gets a the last added mesh using a given id
  32504. * @param id defines the id to search for
  32505. * @return the found mesh or null if not found at all.
  32506. */
  32507. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  32508. /**
  32509. * Gets a the last added node (Mesh, Camera, Light) using a given id
  32510. * @param id defines the id to search for
  32511. * @return the found node or null if not found at all
  32512. */
  32513. getLastEntryByID(id: string): Nullable<Node>;
  32514. /**
  32515. * Gets a node (Mesh, Camera, Light) using a given id
  32516. * @param id defines the id to search for
  32517. * @return the found node or null if not found at all
  32518. */
  32519. getNodeByID(id: string): Nullable<Node>;
  32520. /**
  32521. * Gets a node (Mesh, Camera, Light) using a given name
  32522. * @param name defines the name to search for
  32523. * @return the found node or null if not found at all.
  32524. */
  32525. getNodeByName(name: string): Nullable<Node>;
  32526. /**
  32527. * Gets a mesh using a given name
  32528. * @param name defines the name to search for
  32529. * @return the found mesh or null if not found at all.
  32530. */
  32531. getMeshByName(name: string): Nullable<AbstractMesh>;
  32532. /**
  32533. * Gets a transform node using a given name
  32534. * @param name defines the name to search for
  32535. * @return the found transform node or null if not found at all.
  32536. */
  32537. getTransformNodeByName(name: string): Nullable<TransformNode>;
  32538. /**
  32539. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  32540. * @param id defines the id to search for
  32541. * @return the found skeleton or null if not found at all.
  32542. */
  32543. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  32544. /**
  32545. * Gets a skeleton using a given auto generated unique id
  32546. * @param uniqueId defines the unique id to search for
  32547. * @return the found skeleton or null if not found at all.
  32548. */
  32549. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  32550. /**
  32551. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  32552. * @param id defines the id to search for
  32553. * @return the found skeleton or null if not found at all.
  32554. */
  32555. getSkeletonById(id: string): Nullable<Skeleton>;
  32556. /**
  32557. * Gets a skeleton using a given name
  32558. * @param name defines the name to search for
  32559. * @return the found skeleton or null if not found at all.
  32560. */
  32561. getSkeletonByName(name: string): Nullable<Skeleton>;
  32562. /**
  32563. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  32564. * @param id defines the id to search for
  32565. * @return the found morph target manager or null if not found at all.
  32566. */
  32567. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  32568. /**
  32569. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  32570. * @param id defines the id to search for
  32571. * @return the found morph target or null if not found at all.
  32572. */
  32573. getMorphTargetById(id: string): Nullable<MorphTarget>;
  32574. /**
  32575. * Gets a boolean indicating if the given mesh is active
  32576. * @param mesh defines the mesh to look for
  32577. * @returns true if the mesh is in the active list
  32578. */
  32579. isActiveMesh(mesh: AbstractMesh): boolean;
  32580. /**
  32581. * Return a unique id as a string which can serve as an identifier for the scene
  32582. */
  32583. readonly uid: string;
  32584. /**
  32585. * Add an externaly attached data from its key.
  32586. * This method call will fail and return false, if such key already exists.
  32587. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32588. * @param key the unique key that identifies the data
  32589. * @param data the data object to associate to the key for this Engine instance
  32590. * @return true if no such key were already present and the data was added successfully, false otherwise
  32591. */
  32592. addExternalData<T>(key: string, data: T): boolean;
  32593. /**
  32594. * Get an externaly attached data from its key
  32595. * @param key the unique key that identifies the data
  32596. * @return the associated data, if present (can be null), or undefined if not present
  32597. */
  32598. getExternalData<T>(key: string): Nullable<T>;
  32599. /**
  32600. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32601. * @param key the unique key that identifies the data
  32602. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32603. * @return the associated data, can be null if the factory returned null.
  32604. */
  32605. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32606. /**
  32607. * Remove an externaly attached data from the Engine instance
  32608. * @param key the unique key that identifies the data
  32609. * @return true if the data was successfully removed, false if it doesn't exist
  32610. */
  32611. removeExternalData(key: string): boolean;
  32612. private _evaluateSubMesh;
  32613. /**
  32614. * Clear the processed materials smart array preventing retention point in material dispose.
  32615. */
  32616. freeProcessedMaterials(): void;
  32617. private _preventFreeActiveMeshesAndRenderingGroups;
  32618. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  32619. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  32620. * when disposing several meshes in a row or a hierarchy of meshes.
  32621. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  32622. */
  32623. blockfreeActiveMeshesAndRenderingGroups: boolean;
  32624. /**
  32625. * Clear the active meshes smart array preventing retention point in mesh dispose.
  32626. */
  32627. freeActiveMeshes(): void;
  32628. /**
  32629. * Clear the info related to rendering groups preventing retention points during dispose.
  32630. */
  32631. freeRenderingGroups(): void;
  32632. /** @hidden */ isInIntermediateRendering(): boolean;
  32633. /**
  32634. * Lambda returning the list of potentially active meshes.
  32635. */
  32636. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  32637. /**
  32638. * Lambda returning the list of potentially active sub meshes.
  32639. */
  32640. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  32641. /**
  32642. * Lambda returning the list of potentially intersecting sub meshes.
  32643. */
  32644. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  32645. /**
  32646. * Lambda returning the list of potentially colliding sub meshes.
  32647. */
  32648. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  32649. private _activeMeshesFrozen;
  32650. /**
  32651. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  32652. * @returns the current scene
  32653. */
  32654. freezeActiveMeshes(): Scene;
  32655. /**
  32656. * Use this function to restart evaluating active meshes on every frame
  32657. * @returns the current scene
  32658. */
  32659. unfreezeActiveMeshes(): Scene;
  32660. private _evaluateActiveMeshes;
  32661. private _activeMesh;
  32662. /**
  32663. * Update the transform matrix to update from the current active camera
  32664. * @param force defines a boolean used to force the update even if cache is up to date
  32665. */
  32666. updateTransformMatrix(force?: boolean): void;
  32667. private _bindFrameBuffer;
  32668. /** @hidden */ allowPostProcessClearColor: boolean;
  32669. /** @hidden */ renderForCamera(camera: Camera, rigParent?: Camera): void;
  32670. private _processSubCameras;
  32671. private _checkIntersections;
  32672. /** @hidden */ advancePhysicsEngineStep(step: number): void;
  32673. /**
  32674. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  32675. */
  32676. getDeterministicFrameTime: () => number;
  32677. /** @hidden */ animate(): void;
  32678. /**
  32679. * Render the scene
  32680. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  32681. */
  32682. render(updateCameras?: boolean): void;
  32683. /**
  32684. * Freeze all materials
  32685. * A frozen material will not be updatable but should be faster to render
  32686. */
  32687. freezeMaterials(): void;
  32688. /**
  32689. * Unfreeze all materials
  32690. * A frozen material will not be updatable but should be faster to render
  32691. */
  32692. unfreezeMaterials(): void;
  32693. /**
  32694. * Releases all held ressources
  32695. */
  32696. dispose(): void;
  32697. /**
  32698. * Gets if the scene is already disposed
  32699. */
  32700. readonly isDisposed: boolean;
  32701. /**
  32702. * Call this function to reduce memory footprint of the scene.
  32703. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  32704. */
  32705. clearCachedVertexData(): void;
  32706. /**
  32707. * This function will remove the local cached buffer data from texture.
  32708. * It will save memory but will prevent the texture from being rebuilt
  32709. */
  32710. cleanCachedTextureBuffer(): void;
  32711. /**
  32712. * Get the world extend vectors with an optional filter
  32713. *
  32714. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  32715. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  32716. */
  32717. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  32718. min: Vector3;
  32719. max: Vector3;
  32720. };
  32721. /**
  32722. * Creates a ray that can be used to pick in the scene
  32723. * @param x defines the x coordinate of the origin (on-screen)
  32724. * @param y defines the y coordinate of the origin (on-screen)
  32725. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  32726. * @param camera defines the camera to use for the picking
  32727. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  32728. * @returns a Ray
  32729. */
  32730. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  32731. /**
  32732. * Creates a ray that can be used to pick in the scene
  32733. * @param x defines the x coordinate of the origin (on-screen)
  32734. * @param y defines the y coordinate of the origin (on-screen)
  32735. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  32736. * @param result defines the ray where to store the picking ray
  32737. * @param camera defines the camera to use for the picking
  32738. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  32739. * @returns the current scene
  32740. */
  32741. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  32742. /**
  32743. * Creates a ray that can be used to pick in the scene
  32744. * @param x defines the x coordinate of the origin (on-screen)
  32745. * @param y defines the y coordinate of the origin (on-screen)
  32746. * @param camera defines the camera to use for the picking
  32747. * @returns a Ray
  32748. */
  32749. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  32750. /**
  32751. * Creates a ray that can be used to pick in the scene
  32752. * @param x defines the x coordinate of the origin (on-screen)
  32753. * @param y defines the y coordinate of the origin (on-screen)
  32754. * @param result defines the ray where to store the picking ray
  32755. * @param camera defines the camera to use for the picking
  32756. * @returns the current scene
  32757. */
  32758. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  32759. /** Launch a ray to try to pick a mesh in the scene
  32760. * @param x position on screen
  32761. * @param y position on screen
  32762. * @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
  32763. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  32764. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  32765. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32766. * @returns a PickingInfo
  32767. */
  32768. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  32769. /** Use the given ray to pick a mesh in the scene
  32770. * @param ray The ray to use to pick meshes
  32771. * @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
  32772. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  32773. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32774. * @returns a PickingInfo
  32775. */
  32776. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  32777. /**
  32778. * Launch a ray to try to pick a mesh in the scene
  32779. * @param x X position on screen
  32780. * @param y Y position on screen
  32781. * @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
  32782. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  32783. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32784. * @returns an array of PickingInfo
  32785. */
  32786. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  32787. /**
  32788. * Launch a ray to try to pick a mesh in the scene
  32789. * @param ray Ray to use
  32790. * @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
  32791. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32792. * @returns an array of PickingInfo
  32793. */
  32794. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  32795. /**
  32796. * Force the value of meshUnderPointer
  32797. * @param mesh defines the mesh to use
  32798. */
  32799. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32800. /**
  32801. * Gets the mesh under the pointer
  32802. * @returns a Mesh or null if no mesh is under the pointer
  32803. */
  32804. getPointerOverMesh(): Nullable<AbstractMesh>;
  32805. /** @hidden */ rebuildGeometries(): void;
  32806. /** @hidden */ rebuildTextures(): void;
  32807. private _getByTags;
  32808. /**
  32809. * Get a list of meshes by tags
  32810. * @param tagsQuery defines the tags query to use
  32811. * @param forEach defines a predicate used to filter results
  32812. * @returns an array of Mesh
  32813. */
  32814. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  32815. /**
  32816. * Get a list of cameras by tags
  32817. * @param tagsQuery defines the tags query to use
  32818. * @param forEach defines a predicate used to filter results
  32819. * @returns an array of Camera
  32820. */
  32821. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  32822. /**
  32823. * Get a list of lights by tags
  32824. * @param tagsQuery defines the tags query to use
  32825. * @param forEach defines a predicate used to filter results
  32826. * @returns an array of Light
  32827. */
  32828. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  32829. /**
  32830. * Get a list of materials by tags
  32831. * @param tagsQuery defines the tags query to use
  32832. * @param forEach defines a predicate used to filter results
  32833. * @returns an array of Material
  32834. */
  32835. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  32836. /**
  32837. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  32838. * This allowed control for front to back rendering or reversly depending of the special needs.
  32839. *
  32840. * @param renderingGroupId The rendering group id corresponding to its index
  32841. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  32842. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  32843. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  32844. */
  32845. 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;
  32846. /**
  32847. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  32848. *
  32849. * @param renderingGroupId The rendering group id corresponding to its index
  32850. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  32851. * @param depth Automatically clears depth between groups if true and autoClear is true.
  32852. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  32853. */
  32854. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  32855. /**
  32856. * Gets the current auto clear configuration for one rendering group of the rendering
  32857. * manager.
  32858. * @param index the rendering group index to get the information for
  32859. * @returns The auto clear setup for the requested rendering group
  32860. */
  32861. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  32862. private _blockMaterialDirtyMechanism;
  32863. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  32864. blockMaterialDirtyMechanism: boolean;
  32865. /**
  32866. * Will flag all materials as dirty to trigger new shader compilation
  32867. * @param flag defines the flag used to specify which material part must be marked as dirty
  32868. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  32869. */
  32870. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32871. /** @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;
  32872. /** @hidden */ loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32873. }
  32874. }
  32875. declare module BABYLON {
  32876. /**
  32877. * Set of assets to keep when moving a scene into an asset container.
  32878. */
  32879. export class KeepAssets extends AbstractScene {
  32880. }
  32881. /**
  32882. * Container with a set of assets that can be added or removed from a scene.
  32883. */
  32884. export class AssetContainer extends AbstractScene {
  32885. /**
  32886. * The scene the AssetContainer belongs to.
  32887. */
  32888. scene: Scene;
  32889. /**
  32890. * Instantiates an AssetContainer.
  32891. * @param scene The scene the AssetContainer belongs to.
  32892. */
  32893. constructor(scene: Scene);
  32894. /**
  32895. * Adds all the assets from the container to the scene.
  32896. */
  32897. addAllToScene(): void;
  32898. /**
  32899. * Removes all the assets in the container from the scene
  32900. */
  32901. removeAllFromScene(): void;
  32902. /**
  32903. * Disposes all the assets in the container
  32904. */
  32905. dispose(): void;
  32906. private _moveAssets;
  32907. /**
  32908. * Removes all the assets contained in the scene and adds them to the container.
  32909. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  32910. */
  32911. moveAllFromScene(keepAssets?: KeepAssets): void;
  32912. /**
  32913. * 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.
  32914. * @returns the root mesh
  32915. */
  32916. createRootMesh(): Mesh;
  32917. }
  32918. }
  32919. declare module BABYLON {
  32920. /**
  32921. * Defines how the parser contract is defined.
  32922. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  32923. */
  32924. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  32925. /**
  32926. * Defines how the individual parser contract is defined.
  32927. * These parser can parse an individual asset
  32928. */
  32929. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  32930. /**
  32931. * Base class of the scene acting as a container for the different elements composing a scene.
  32932. * This class is dynamically extended by the different components of the scene increasing
  32933. * flexibility and reducing coupling
  32934. */
  32935. export abstract class AbstractScene {
  32936. /**
  32937. * Stores the list of available parsers in the application.
  32938. */
  32939. private static _BabylonFileParsers;
  32940. /**
  32941. * Stores the list of available individual parsers in the application.
  32942. */
  32943. private static _IndividualBabylonFileParsers;
  32944. /**
  32945. * Adds a parser in the list of available ones
  32946. * @param name Defines the name of the parser
  32947. * @param parser Defines the parser to add
  32948. */
  32949. static AddParser(name: string, parser: BabylonFileParser): void;
  32950. /**
  32951. * Gets a general parser from the list of avaialble ones
  32952. * @param name Defines the name of the parser
  32953. * @returns the requested parser or null
  32954. */
  32955. static GetParser(name: string): Nullable<BabylonFileParser>;
  32956. /**
  32957. * Adds n individual parser in the list of available ones
  32958. * @param name Defines the name of the parser
  32959. * @param parser Defines the parser to add
  32960. */
  32961. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  32962. /**
  32963. * Gets an individual parser from the list of avaialble ones
  32964. * @param name Defines the name of the parser
  32965. * @returns the requested parser or null
  32966. */
  32967. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  32968. /**
  32969. * Parser json data and populate both a scene and its associated container object
  32970. * @param jsonData Defines the data to parse
  32971. * @param scene Defines the scene to parse the data for
  32972. * @param container Defines the container attached to the parsing sequence
  32973. * @param rootUrl Defines the root url of the data
  32974. */
  32975. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  32976. /**
  32977. * Gets the list of root nodes (ie. nodes with no parent)
  32978. */
  32979. rootNodes: Node[];
  32980. /** All of the cameras added to this scene
  32981. * @see http://doc.babylonjs.com/babylon101/cameras
  32982. */
  32983. cameras: Camera[];
  32984. /**
  32985. * All of the lights added to this scene
  32986. * @see http://doc.babylonjs.com/babylon101/lights
  32987. */
  32988. lights: Light[];
  32989. /**
  32990. * All of the (abstract) meshes added to this scene
  32991. */
  32992. meshes: AbstractMesh[];
  32993. /**
  32994. * The list of skeletons added to the scene
  32995. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32996. */
  32997. skeletons: Skeleton[];
  32998. /**
  32999. * All of the particle systems added to this scene
  33000. * @see http://doc.babylonjs.com/babylon101/particles
  33001. */
  33002. particleSystems: IParticleSystem[];
  33003. /**
  33004. * Gets a list of Animations associated with the scene
  33005. */
  33006. animations: Animation[];
  33007. /**
  33008. * All of the animation groups added to this scene
  33009. * @see http://doc.babylonjs.com/how_to/group
  33010. */
  33011. animationGroups: AnimationGroup[];
  33012. /**
  33013. * All of the multi-materials added to this scene
  33014. * @see http://doc.babylonjs.com/how_to/multi_materials
  33015. */
  33016. multiMaterials: MultiMaterial[];
  33017. /**
  33018. * All of the materials added to this scene
  33019. * In the context of a Scene, it is not supposed to be modified manually.
  33020. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33021. * Note also that the order of the Material wihin the array is not significant and might change.
  33022. * @see http://doc.babylonjs.com/babylon101/materials
  33023. */
  33024. materials: Material[];
  33025. /**
  33026. * The list of morph target managers added to the scene
  33027. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33028. */
  33029. morphTargetManagers: MorphTargetManager[];
  33030. /**
  33031. * The list of geometries used in the scene.
  33032. */
  33033. geometries: Geometry[];
  33034. /**
  33035. * All of the tranform nodes added to this scene
  33036. * In the context of a Scene, it is not supposed to be modified manually.
  33037. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33038. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33039. * @see http://doc.babylonjs.com/how_to/transformnode
  33040. */
  33041. transformNodes: TransformNode[];
  33042. /**
  33043. * ActionManagers available on the scene.
  33044. */
  33045. actionManagers: AbstractActionManager[];
  33046. /**
  33047. * Textures to keep.
  33048. */
  33049. textures: BaseTexture[];
  33050. /**
  33051. * Environment texture for the scene
  33052. */
  33053. environmentTexture: Nullable<BaseTexture>;
  33054. }
  33055. }
  33056. declare module BABYLON {
  33057. /**
  33058. * Defines a sound that can be played in the application.
  33059. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33060. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33061. */
  33062. export class Sound {
  33063. /**
  33064. * The name of the sound in the scene.
  33065. */
  33066. name: string;
  33067. /**
  33068. * Does the sound autoplay once loaded.
  33069. */
  33070. autoplay: boolean;
  33071. /**
  33072. * Does the sound loop after it finishes playing once.
  33073. */
  33074. loop: boolean;
  33075. /**
  33076. * Does the sound use a custom attenuation curve to simulate the falloff
  33077. * happening when the source gets further away from the camera.
  33078. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33079. */
  33080. useCustomAttenuation: boolean;
  33081. /**
  33082. * The sound track id this sound belongs to.
  33083. */
  33084. soundTrackId: number;
  33085. /**
  33086. * Is this sound currently played.
  33087. */
  33088. isPlaying: boolean;
  33089. /**
  33090. * Is this sound currently paused.
  33091. */
  33092. isPaused: boolean;
  33093. /**
  33094. * Does this sound enables spatial sound.
  33095. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33096. */
  33097. spatialSound: boolean;
  33098. /**
  33099. * Define the reference distance the sound should be heard perfectly.
  33100. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33101. */
  33102. refDistance: number;
  33103. /**
  33104. * Define the roll off factor of spatial sounds.
  33105. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33106. */
  33107. rolloffFactor: number;
  33108. /**
  33109. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33110. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33111. */
  33112. maxDistance: number;
  33113. /**
  33114. * Define the distance attenuation model the sound will follow.
  33115. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33116. */
  33117. distanceModel: string;
  33118. /**
  33119. * @hidden
  33120. * Back Compat
  33121. **/
  33122. onended: () => any;
  33123. /**
  33124. * Observable event when the current playing sound finishes.
  33125. */
  33126. onEndedObservable: Observable<Sound>;
  33127. private _panningModel;
  33128. private _playbackRate;
  33129. private _streaming;
  33130. private _startTime;
  33131. private _startOffset;
  33132. private _position;
  33133. /** @hidden */ positionInEmitterSpace: boolean;
  33134. private _localDirection;
  33135. private _volume;
  33136. private _isReadyToPlay;
  33137. private _isDirectional;
  33138. private _readyToPlayCallback;
  33139. private _audioBuffer;
  33140. private _soundSource;
  33141. private _streamingSource;
  33142. private _soundPanner;
  33143. private _soundGain;
  33144. private _inputAudioNode;
  33145. private _outputAudioNode;
  33146. private _coneInnerAngle;
  33147. private _coneOuterAngle;
  33148. private _coneOuterGain;
  33149. private _scene;
  33150. private _connectedTransformNode;
  33151. private _customAttenuationFunction;
  33152. private _registerFunc;
  33153. private _isOutputConnected;
  33154. private _htmlAudioElement;
  33155. private _urlType;
  33156. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  33157. /**
  33158. * Create a sound and attach it to a scene
  33159. * @param name Name of your sound
  33160. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33161. * @param scene defines the scene the sound belongs to
  33162. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33163. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33164. */
  33165. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33166. /**
  33167. * Release the sound and its associated resources
  33168. */
  33169. dispose(): void;
  33170. /**
  33171. * Gets if the sounds is ready to be played or not.
  33172. * @returns true if ready, otherwise false
  33173. */
  33174. isReady(): boolean;
  33175. private _soundLoaded;
  33176. /**
  33177. * Sets the data of the sound from an audiobuffer
  33178. * @param audioBuffer The audioBuffer containing the data
  33179. */
  33180. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33181. /**
  33182. * Updates the current sounds options such as maxdistance, loop...
  33183. * @param options A JSON object containing values named as the object properties
  33184. */
  33185. updateOptions(options: any): void;
  33186. private _createSpatialParameters;
  33187. private _updateSpatialParameters;
  33188. /**
  33189. * Switch the panning model to HRTF:
  33190. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33191. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33192. */
  33193. switchPanningModelToHRTF(): void;
  33194. /**
  33195. * Switch the panning model to Equal Power:
  33196. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33197. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33198. */
  33199. switchPanningModelToEqualPower(): void;
  33200. private _switchPanningModel;
  33201. /**
  33202. * Connect this sound to a sound track audio node like gain...
  33203. * @param soundTrackAudioNode the sound track audio node to connect to
  33204. */
  33205. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33206. /**
  33207. * Transform this sound into a directional source
  33208. * @param coneInnerAngle Size of the inner cone in degree
  33209. * @param coneOuterAngle Size of the outer cone in degree
  33210. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33211. */
  33212. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33213. /**
  33214. * Gets or sets the inner angle for the directional cone.
  33215. */
  33216. /**
  33217. * Gets or sets the inner angle for the directional cone.
  33218. */
  33219. directionalConeInnerAngle: number;
  33220. /**
  33221. * Gets or sets the outer angle for the directional cone.
  33222. */
  33223. /**
  33224. * Gets or sets the outer angle for the directional cone.
  33225. */
  33226. directionalConeOuterAngle: number;
  33227. /**
  33228. * Sets the position of the emitter if spatial sound is enabled
  33229. * @param newPosition Defines the new posisiton
  33230. */
  33231. setPosition(newPosition: Vector3): void;
  33232. /**
  33233. * Sets the local direction of the emitter if spatial sound is enabled
  33234. * @param newLocalDirection Defines the new local direction
  33235. */
  33236. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33237. private _updateDirection;
  33238. /** @hidden */
  33239. updateDistanceFromListener(): void;
  33240. /**
  33241. * Sets a new custom attenuation function for the sound.
  33242. * @param callback Defines the function used for the attenuation
  33243. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33244. */
  33245. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33246. /**
  33247. * Play the sound
  33248. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33249. * @param offset (optional) Start the sound setting it at a specific time
  33250. */
  33251. play(time?: number, offset?: number): void;
  33252. private _onended;
  33253. /**
  33254. * Stop the sound
  33255. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33256. */
  33257. stop(time?: number): void;
  33258. /**
  33259. * Put the sound in pause
  33260. */
  33261. pause(): void;
  33262. /**
  33263. * Sets a dedicated volume for this sounds
  33264. * @param newVolume Define the new volume of the sound
  33265. * @param time Define in how long the sound should be at this value
  33266. */
  33267. setVolume(newVolume: number, time?: number): void;
  33268. /**
  33269. * Set the sound play back rate
  33270. * @param newPlaybackRate Define the playback rate the sound should be played at
  33271. */
  33272. setPlaybackRate(newPlaybackRate: number): void;
  33273. /**
  33274. * Gets the volume of the sound.
  33275. * @returns the volume of the sound
  33276. */
  33277. getVolume(): number;
  33278. /**
  33279. * Attach the sound to a dedicated mesh
  33280. * @param transformNode The transform node to connect the sound with
  33281. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33282. */
  33283. attachToMesh(transformNode: TransformNode): void;
  33284. /**
  33285. * Detach the sound from the previously attached mesh
  33286. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33287. */
  33288. detachFromMesh(): void;
  33289. private _onRegisterAfterWorldMatrixUpdate;
  33290. /**
  33291. * Clone the current sound in the scene.
  33292. * @returns the new sound clone
  33293. */
  33294. clone(): Nullable<Sound>;
  33295. /**
  33296. * Gets the current underlying audio buffer containing the data
  33297. * @returns the audio buffer
  33298. */
  33299. getAudioBuffer(): Nullable<AudioBuffer>;
  33300. /**
  33301. * Serializes the Sound in a JSON representation
  33302. * @returns the JSON representation of the sound
  33303. */
  33304. serialize(): any;
  33305. /**
  33306. * Parse a JSON representation of a sound to innstantiate in a given scene
  33307. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33308. * @param scene Define the scene the new parsed sound should be created in
  33309. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33310. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33311. * @returns the newly parsed sound
  33312. */
  33313. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33314. }
  33315. }
  33316. declare module BABYLON {
  33317. /**
  33318. * This defines an action helpful to play a defined sound on a triggered action.
  33319. */
  33320. export class PlaySoundAction extends Action {
  33321. private _sound;
  33322. /**
  33323. * Instantiate the action
  33324. * @param triggerOptions defines the trigger options
  33325. * @param sound defines the sound to play
  33326. * @param condition defines the trigger related conditions
  33327. */
  33328. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33329. /** @hidden */ prepare(): void;
  33330. /**
  33331. * Execute the action and play the sound.
  33332. */
  33333. execute(): void;
  33334. /**
  33335. * Serializes the actions and its related information.
  33336. * @param parent defines the object to serialize in
  33337. * @returns the serialized object
  33338. */
  33339. serialize(parent: any): any;
  33340. }
  33341. /**
  33342. * This defines an action helpful to stop a defined sound on a triggered action.
  33343. */
  33344. export class StopSoundAction extends Action {
  33345. private _sound;
  33346. /**
  33347. * Instantiate the action
  33348. * @param triggerOptions defines the trigger options
  33349. * @param sound defines the sound to stop
  33350. * @param condition defines the trigger related conditions
  33351. */
  33352. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33353. /** @hidden */ prepare(): void;
  33354. /**
  33355. * Execute the action and stop the sound.
  33356. */
  33357. execute(): void;
  33358. /**
  33359. * Serializes the actions and its related information.
  33360. * @param parent defines the object to serialize in
  33361. * @returns the serialized object
  33362. */
  33363. serialize(parent: any): any;
  33364. }
  33365. }
  33366. declare module BABYLON {
  33367. /**
  33368. * This defines an action responsible to change the value of a property
  33369. * by interpolating between its current value and the newly set one once triggered.
  33370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33371. */
  33372. export class InterpolateValueAction extends Action {
  33373. /**
  33374. * Defines the path of the property where the value should be interpolated
  33375. */
  33376. propertyPath: string;
  33377. /**
  33378. * Defines the target value at the end of the interpolation.
  33379. */
  33380. value: any;
  33381. /**
  33382. * Defines the time it will take for the property to interpolate to the value.
  33383. */
  33384. duration: number;
  33385. /**
  33386. * Defines if the other scene animations should be stopped when the action has been triggered
  33387. */
  33388. stopOtherAnimations?: boolean;
  33389. /**
  33390. * Defines a callback raised once the interpolation animation has been done.
  33391. */
  33392. onInterpolationDone?: () => void;
  33393. /**
  33394. * Observable triggered once the interpolation animation has been done.
  33395. */
  33396. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  33397. private _target;
  33398. private _effectiveTarget;
  33399. private _property;
  33400. /**
  33401. * Instantiate the action
  33402. * @param triggerOptions defines the trigger options
  33403. * @param target defines the object containing the value to interpolate
  33404. * @param propertyPath defines the path to the property in the target object
  33405. * @param value defines the target value at the end of the interpolation
  33406. * @param duration deines the time it will take for the property to interpolate to the value.
  33407. * @param condition defines the trigger related conditions
  33408. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  33409. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  33410. */
  33411. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  33412. /** @hidden */ prepare(): void;
  33413. /**
  33414. * Execute the action starts the value interpolation.
  33415. */
  33416. execute(): void;
  33417. /**
  33418. * Serializes the actions and its related information.
  33419. * @param parent defines the object to serialize in
  33420. * @returns the serialized object
  33421. */
  33422. serialize(parent: any): any;
  33423. }
  33424. }
  33425. declare module BABYLON {
  33426. /**
  33427. * Options allowed during the creation of a sound track.
  33428. */
  33429. export interface ISoundTrackOptions {
  33430. /**
  33431. * The volume the sound track should take during creation
  33432. */
  33433. volume?: number;
  33434. /**
  33435. * Define if the sound track is the main sound track of the scene
  33436. */
  33437. mainTrack?: boolean;
  33438. }
  33439. /**
  33440. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  33441. * It will be also used in a future release to apply effects on a specific track.
  33442. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33443. */
  33444. export class SoundTrack {
  33445. /**
  33446. * The unique identifier of the sound track in the scene.
  33447. */
  33448. id: number;
  33449. /**
  33450. * The list of sounds included in the sound track.
  33451. */
  33452. soundCollection: Array<Sound>;
  33453. private _outputAudioNode;
  33454. private _scene;
  33455. private _isMainTrack;
  33456. private _connectedAnalyser;
  33457. private _options;
  33458. private _isInitialized;
  33459. /**
  33460. * Creates a new sound track.
  33461. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33462. * @param scene Define the scene the sound track belongs to
  33463. * @param options
  33464. */
  33465. constructor(scene: Scene, options?: ISoundTrackOptions);
  33466. private _initializeSoundTrackAudioGraph;
  33467. /**
  33468. * Release the sound track and its associated resources
  33469. */
  33470. dispose(): void;
  33471. /**
  33472. * Adds a sound to this sound track
  33473. * @param sound define the cound to add
  33474. * @ignoreNaming
  33475. */
  33476. AddSound(sound: Sound): void;
  33477. /**
  33478. * Removes a sound to this sound track
  33479. * @param sound define the cound to remove
  33480. * @ignoreNaming
  33481. */
  33482. RemoveSound(sound: Sound): void;
  33483. /**
  33484. * Set a global volume for the full sound track.
  33485. * @param newVolume Define the new volume of the sound track
  33486. */
  33487. setVolume(newVolume: number): void;
  33488. /**
  33489. * Switch the panning model to HRTF:
  33490. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33491. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33492. */
  33493. switchPanningModelToHRTF(): void;
  33494. /**
  33495. * Switch the panning model to Equal Power:
  33496. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33497. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33498. */
  33499. switchPanningModelToEqualPower(): void;
  33500. /**
  33501. * Connect the sound track to an audio analyser allowing some amazing
  33502. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33503. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33504. * @param analyser The analyser to connect to the engine
  33505. */
  33506. connectToAnalyser(analyser: Analyser): void;
  33507. }
  33508. }
  33509. declare module BABYLON {
  33510. interface AbstractScene {
  33511. /**
  33512. * The list of sounds used in the scene.
  33513. */
  33514. sounds: Nullable<Array<Sound>>;
  33515. }
  33516. interface Scene {
  33517. /**
  33518. * @hidden
  33519. * Backing field
  33520. */ mainSoundTrack: SoundTrack;
  33521. /**
  33522. * The main sound track played by the scene.
  33523. * It cotains your primary collection of sounds.
  33524. */
  33525. mainSoundTrack: SoundTrack;
  33526. /**
  33527. * The list of sound tracks added to the scene
  33528. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33529. */
  33530. soundTracks: Nullable<Array<SoundTrack>>;
  33531. /**
  33532. * Gets a sound using a given name
  33533. * @param name defines the name to search for
  33534. * @return the found sound or null if not found at all.
  33535. */
  33536. getSoundByName(name: string): Nullable<Sound>;
  33537. /**
  33538. * Gets or sets if audio support is enabled
  33539. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33540. */
  33541. audioEnabled: boolean;
  33542. /**
  33543. * Gets or sets if audio will be output to headphones
  33544. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33545. */
  33546. headphone: boolean;
  33547. }
  33548. /**
  33549. * Defines the sound scene component responsible to manage any sounds
  33550. * in a given scene.
  33551. */
  33552. export class AudioSceneComponent implements ISceneSerializableComponent {
  33553. /**
  33554. * The component name helpfull to identify the component in the list of scene components.
  33555. */
  33556. readonly name: string;
  33557. /**
  33558. * The scene the component belongs to.
  33559. */
  33560. scene: Scene;
  33561. private _audioEnabled;
  33562. /**
  33563. * Gets whether audio is enabled or not.
  33564. * Please use related enable/disable method to switch state.
  33565. */
  33566. readonly audioEnabled: boolean;
  33567. private _headphone;
  33568. /**
  33569. * Gets whether audio is outputing to headphone or not.
  33570. * Please use the according Switch methods to change output.
  33571. */
  33572. readonly headphone: boolean;
  33573. /**
  33574. * Creates a new instance of the component for the given scene
  33575. * @param scene Defines the scene to register the component in
  33576. */
  33577. constructor(scene: Scene);
  33578. /**
  33579. * Registers the component in a given scene
  33580. */
  33581. register(): void;
  33582. /**
  33583. * Rebuilds the elements related to this component in case of
  33584. * context lost for instance.
  33585. */
  33586. rebuild(): void;
  33587. /**
  33588. * Serializes the component data to the specified json object
  33589. * @param serializationObject The object to serialize to
  33590. */
  33591. serialize(serializationObject: any): void;
  33592. /**
  33593. * Adds all the element from the container to the scene
  33594. * @param container the container holding the elements
  33595. */
  33596. addFromContainer(container: AbstractScene): void;
  33597. /**
  33598. * Removes all the elements in the container from the scene
  33599. * @param container contains the elements to remove
  33600. * @param dispose if the removed element should be disposed (default: false)
  33601. */
  33602. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  33603. /**
  33604. * Disposes the component and the associated ressources.
  33605. */
  33606. dispose(): void;
  33607. /**
  33608. * Disables audio in the associated scene.
  33609. */
  33610. disableAudio(): void;
  33611. /**
  33612. * Enables audio in the associated scene.
  33613. */
  33614. enableAudio(): void;
  33615. /**
  33616. * Switch audio to headphone output.
  33617. */
  33618. switchAudioModeForHeadphones(): void;
  33619. /**
  33620. * Switch audio to normal speakers.
  33621. */
  33622. switchAudioModeForNormalSpeakers(): void;
  33623. private _afterRender;
  33624. }
  33625. }
  33626. declare module BABYLON {
  33627. /**
  33628. * Wraps one or more Sound objects and selects one with random weight for playback.
  33629. */
  33630. export class WeightedSound {
  33631. /** When true a Sound will be selected and played when the current playing Sound completes. */
  33632. loop: boolean;
  33633. private _coneInnerAngle;
  33634. private _coneOuterAngle;
  33635. private _volume;
  33636. /** A Sound is currently playing. */
  33637. isPlaying: boolean;
  33638. /** A Sound is currently paused. */
  33639. isPaused: boolean;
  33640. private _sounds;
  33641. private _weights;
  33642. private _currentIndex?;
  33643. /**
  33644. * Creates a new WeightedSound from the list of sounds given.
  33645. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  33646. * @param sounds Array of Sounds that will be selected from.
  33647. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  33648. */
  33649. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  33650. /**
  33651. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  33652. */
  33653. /**
  33654. * The size of cone in degress for a directional sound in which there will be no attenuation.
  33655. */
  33656. directionalConeInnerAngle: number;
  33657. /**
  33658. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  33659. * Listener angles between innerAngle and outerAngle will falloff linearly.
  33660. */
  33661. /**
  33662. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  33663. * Listener angles between innerAngle and outerAngle will falloff linearly.
  33664. */
  33665. directionalConeOuterAngle: number;
  33666. /**
  33667. * Playback volume.
  33668. */
  33669. /**
  33670. * Playback volume.
  33671. */
  33672. volume: number;
  33673. private _onended;
  33674. /**
  33675. * Suspend playback
  33676. */
  33677. pause(): void;
  33678. /**
  33679. * Stop playback
  33680. */
  33681. stop(): void;
  33682. /**
  33683. * Start playback.
  33684. * @param startOffset Position the clip head at a specific time in seconds.
  33685. */
  33686. play(startOffset?: number): void;
  33687. }
  33688. }
  33689. declare module BABYLON {
  33690. /**
  33691. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  33692. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  33693. */
  33694. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  33695. /**
  33696. * Gets the name of the behavior.
  33697. */
  33698. readonly name: string;
  33699. /**
  33700. * The easing function used by animations
  33701. */
  33702. static EasingFunction: BackEase;
  33703. /**
  33704. * The easing mode used by animations
  33705. */
  33706. static EasingMode: number;
  33707. /**
  33708. * The duration of the animation, in milliseconds
  33709. */
  33710. transitionDuration: number;
  33711. /**
  33712. * Length of the distance animated by the transition when lower radius is reached
  33713. */
  33714. lowerRadiusTransitionRange: number;
  33715. /**
  33716. * Length of the distance animated by the transition when upper radius is reached
  33717. */
  33718. upperRadiusTransitionRange: number;
  33719. private _autoTransitionRange;
  33720. /**
  33721. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  33722. */
  33723. /**
  33724. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  33725. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  33726. */
  33727. autoTransitionRange: boolean;
  33728. private _attachedCamera;
  33729. private _onAfterCheckInputsObserver;
  33730. private _onMeshTargetChangedObserver;
  33731. /**
  33732. * Initializes the behavior.
  33733. */
  33734. init(): void;
  33735. /**
  33736. * Attaches the behavior to its arc rotate camera.
  33737. * @param camera Defines the camera to attach the behavior to
  33738. */
  33739. attach(camera: ArcRotateCamera): void;
  33740. /**
  33741. * Detaches the behavior from its current arc rotate camera.
  33742. */
  33743. detach(): void;
  33744. private _radiusIsAnimating;
  33745. private _radiusBounceTransition;
  33746. private _animatables;
  33747. private _cachedWheelPrecision;
  33748. /**
  33749. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  33750. * @param radiusLimit The limit to check against.
  33751. * @return Bool to indicate if at limit.
  33752. */
  33753. private _isRadiusAtLimit;
  33754. /**
  33755. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  33756. * @param radiusDelta The delta by which to animate to. Can be negative.
  33757. */
  33758. private _applyBoundRadiusAnimation;
  33759. /**
  33760. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  33761. */
  33762. protected _clearAnimationLocks(): void;
  33763. /**
  33764. * Stops and removes all animations that have been applied to the camera
  33765. */
  33766. stopAllAnimations(): void;
  33767. }
  33768. }
  33769. declare module BABYLON {
  33770. /**
  33771. * 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.
  33772. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  33773. */
  33774. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  33775. /**
  33776. * Gets the name of the behavior.
  33777. */
  33778. readonly name: string;
  33779. private _mode;
  33780. private _radiusScale;
  33781. private _positionScale;
  33782. private _defaultElevation;
  33783. private _elevationReturnTime;
  33784. private _elevationReturnWaitTime;
  33785. private _zoomStopsAnimation;
  33786. private _framingTime;
  33787. /**
  33788. * The easing function used by animations
  33789. */
  33790. static EasingFunction: ExponentialEase;
  33791. /**
  33792. * The easing mode used by animations
  33793. */
  33794. static EasingMode: number;
  33795. /**
  33796. * Sets the current mode used by the behavior
  33797. */
  33798. /**
  33799. * Gets current mode used by the behavior.
  33800. */
  33801. mode: number;
  33802. /**
  33803. * Sets the scale applied to the radius (1 by default)
  33804. */
  33805. /**
  33806. * Gets the scale applied to the radius
  33807. */
  33808. radiusScale: number;
  33809. /**
  33810. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33811. */
  33812. /**
  33813. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33814. */
  33815. positionScale: number;
  33816. /**
  33817. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33818. * behaviour is triggered, in radians.
  33819. */
  33820. /**
  33821. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33822. * behaviour is triggered, in radians.
  33823. */
  33824. defaultElevation: number;
  33825. /**
  33826. * Sets the time (in milliseconds) taken to return to the default beta position.
  33827. * Negative value indicates camera should not return to default.
  33828. */
  33829. /**
  33830. * Gets the time (in milliseconds) taken to return to the default beta position.
  33831. * Negative value indicates camera should not return to default.
  33832. */
  33833. elevationReturnTime: number;
  33834. /**
  33835. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  33836. */
  33837. /**
  33838. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  33839. */
  33840. elevationReturnWaitTime: number;
  33841. /**
  33842. * Sets the flag that indicates if user zooming should stop animation.
  33843. */
  33844. /**
  33845. * Gets the flag that indicates if user zooming should stop animation.
  33846. */
  33847. zoomStopsAnimation: boolean;
  33848. /**
  33849. * Sets the transition time when framing the mesh, in milliseconds
  33850. */
  33851. /**
  33852. * Gets the transition time when framing the mesh, in milliseconds
  33853. */
  33854. framingTime: number;
  33855. /**
  33856. * Define if the behavior should automatically change the configured
  33857. * camera limits and sensibilities.
  33858. */
  33859. autoCorrectCameraLimitsAndSensibility: boolean;
  33860. private _onPrePointerObservableObserver;
  33861. private _onAfterCheckInputsObserver;
  33862. private _onMeshTargetChangedObserver;
  33863. private _attachedCamera;
  33864. private _isPointerDown;
  33865. private _lastInteractionTime;
  33866. /**
  33867. * Initializes the behavior.
  33868. */
  33869. init(): void;
  33870. /**
  33871. * Attaches the behavior to its arc rotate camera.
  33872. * @param camera Defines the camera to attach the behavior to
  33873. */
  33874. attach(camera: ArcRotateCamera): void;
  33875. /**
  33876. * Detaches the behavior from its current arc rotate camera.
  33877. */
  33878. detach(): void;
  33879. private _animatables;
  33880. private _betaIsAnimating;
  33881. private _betaTransition;
  33882. private _radiusTransition;
  33883. private _vectorTransition;
  33884. /**
  33885. * Targets the given mesh and updates zoom level accordingly.
  33886. * @param mesh The mesh to target.
  33887. * @param radius Optional. If a cached radius position already exists, overrides default.
  33888. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33889. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33890. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33891. */
  33892. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33893. /**
  33894. * Targets the given mesh with its children and updates zoom level accordingly.
  33895. * @param mesh The mesh to target.
  33896. * @param radius Optional. If a cached radius position already exists, overrides default.
  33897. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33898. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33899. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33900. */
  33901. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33902. /**
  33903. * Targets the given meshes with their children and updates zoom level accordingly.
  33904. * @param meshes The mesh to target.
  33905. * @param radius Optional. If a cached radius position already exists, overrides default.
  33906. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33907. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33908. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33909. */
  33910. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33911. /**
  33912. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  33913. * @param minimumWorld Determines the smaller position of the bounding box extend
  33914. * @param maximumWorld Determines the bigger position of the bounding box extend
  33915. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33916. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33917. */
  33918. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33919. /**
  33920. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  33921. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  33922. * frustum width.
  33923. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  33924. * to fully enclose the mesh in the viewing frustum.
  33925. */
  33926. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  33927. /**
  33928. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  33929. * is automatically returned to its default position (expected to be above ground plane).
  33930. */
  33931. private _maintainCameraAboveGround;
  33932. /**
  33933. * Returns the frustum slope based on the canvas ratio and camera FOV
  33934. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  33935. */
  33936. private _getFrustumSlope;
  33937. /**
  33938. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  33939. */
  33940. private _clearAnimationLocks;
  33941. /**
  33942. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  33943. */
  33944. private _applyUserInteraction;
  33945. /**
  33946. * Stops and removes all animations that have been applied to the camera
  33947. */
  33948. stopAllAnimations(): void;
  33949. /**
  33950. * Gets a value indicating if the user is moving the camera
  33951. */
  33952. readonly isUserIsMoving: boolean;
  33953. /**
  33954. * The camera can move all the way towards the mesh.
  33955. */
  33956. static IgnoreBoundsSizeMode: number;
  33957. /**
  33958. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  33959. */
  33960. static FitFrustumSidesMode: number;
  33961. }
  33962. }
  33963. declare module BABYLON {
  33964. /**
  33965. * Base class for Camera Pointer Inputs.
  33966. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  33967. * for example usage.
  33968. */
  33969. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  33970. /**
  33971. * Defines the camera the input is attached to.
  33972. */
  33973. abstract camera: Camera;
  33974. /**
  33975. * Whether keyboard modifier keys are pressed at time of last mouse event.
  33976. */
  33977. protected _altKey: boolean;
  33978. protected _ctrlKey: boolean;
  33979. protected _metaKey: boolean;
  33980. protected _shiftKey: boolean;
  33981. /**
  33982. * Which mouse buttons were pressed at time of last mouse event.
  33983. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  33984. */
  33985. protected _buttonsPressed: number;
  33986. /**
  33987. * Defines the buttons associated with the input to handle camera move.
  33988. */
  33989. buttons: number[];
  33990. /**
  33991. * Attach the input controls to a specific dom element to get the input from.
  33992. * @param element Defines the element the controls should be listened from
  33993. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  33994. */
  33995. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33996. /**
  33997. * Detach the current controls from the specified dom element.
  33998. * @param element Defines the element to stop listening the inputs from
  33999. */
  34000. detachControl(element: Nullable<HTMLElement>): void;
  34001. /**
  34002. * Gets the class name of the current input.
  34003. * @returns the class name
  34004. */
  34005. getClassName(): string;
  34006. /**
  34007. * Get the friendly name associated with the input class.
  34008. * @returns the input friendly name
  34009. */
  34010. getSimpleName(): string;
  34011. /**
  34012. * Called on pointer POINTERDOUBLETAP event.
  34013. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34014. */
  34015. protected onDoubleTap(type: string): void;
  34016. /**
  34017. * Called on pointer POINTERMOVE event if only a single touch is active.
  34018. * Override this method to provide functionality.
  34019. */
  34020. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34021. /**
  34022. * Called on pointer POINTERMOVE event if multiple touches are active.
  34023. * Override this method to provide functionality.
  34024. */
  34025. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34026. /**
  34027. * Called on JS contextmenu event.
  34028. * Override this method to provide functionality.
  34029. */
  34030. protected onContextMenu(evt: PointerEvent): void;
  34031. /**
  34032. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34033. * press.
  34034. * Override this method to provide functionality.
  34035. */
  34036. protected onButtonDown(evt: PointerEvent): void;
  34037. /**
  34038. * Called each time a new POINTERUP event occurs. Ie, for each button
  34039. * release.
  34040. * Override this method to provide functionality.
  34041. */
  34042. protected onButtonUp(evt: PointerEvent): void;
  34043. /**
  34044. * Called when window becomes inactive.
  34045. * Override this method to provide functionality.
  34046. */
  34047. protected onLostFocus(): void;
  34048. private _pointerInput;
  34049. private _observer;
  34050. private _onLostFocus;
  34051. private pointA;
  34052. private pointB;
  34053. }
  34054. }
  34055. declare module BABYLON {
  34056. /**
  34057. * Manage the pointers inputs to control an arc rotate camera.
  34058. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34059. */
  34060. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34061. /**
  34062. * Defines the camera the input is attached to.
  34063. */
  34064. camera: ArcRotateCamera;
  34065. /**
  34066. * Gets the class name of the current input.
  34067. * @returns the class name
  34068. */
  34069. getClassName(): string;
  34070. /**
  34071. * Defines the buttons associated with the input to handle camera move.
  34072. */
  34073. buttons: number[];
  34074. /**
  34075. * Defines the pointer angular sensibility along the X axis or how fast is
  34076. * the camera rotating.
  34077. */
  34078. angularSensibilityX: number;
  34079. /**
  34080. * Defines the pointer angular sensibility along the Y axis or how fast is
  34081. * the camera rotating.
  34082. */
  34083. angularSensibilityY: number;
  34084. /**
  34085. * Defines the pointer pinch precision or how fast is the camera zooming.
  34086. */
  34087. pinchPrecision: number;
  34088. /**
  34089. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34090. * from 0.
  34091. * It defines the percentage of current camera.radius to use as delta when
  34092. * pinch zoom is used.
  34093. */
  34094. pinchDeltaPercentage: number;
  34095. /**
  34096. * Defines the pointer panning sensibility or how fast is the camera moving.
  34097. */
  34098. panningSensibility: number;
  34099. /**
  34100. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34101. */
  34102. multiTouchPanning: boolean;
  34103. /**
  34104. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34105. * zoom (pinch) through multitouch.
  34106. */
  34107. multiTouchPanAndZoom: boolean;
  34108. /**
  34109. * Revers pinch action direction.
  34110. */
  34111. pinchInwards: boolean;
  34112. private _isPanClick;
  34113. private _twoFingerActivityCount;
  34114. private _isPinching;
  34115. /**
  34116. * Called on pointer POINTERMOVE event if only a single touch is active.
  34117. */
  34118. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34119. /**
  34120. * Called on pointer POINTERDOUBLETAP event.
  34121. */
  34122. protected onDoubleTap(type: string): void;
  34123. /**
  34124. * Called on pointer POINTERMOVE event if multiple touches are active.
  34125. */
  34126. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34127. /**
  34128. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34129. * press.
  34130. */
  34131. protected onButtonDown(evt: PointerEvent): void;
  34132. /**
  34133. * Called each time a new POINTERUP event occurs. Ie, for each button
  34134. * release.
  34135. */
  34136. protected onButtonUp(evt: PointerEvent): void;
  34137. /**
  34138. * Called when window becomes inactive.
  34139. */
  34140. protected onLostFocus(): void;
  34141. }
  34142. }
  34143. declare module BABYLON {
  34144. /**
  34145. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34146. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34147. */
  34148. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34149. /**
  34150. * Defines the camera the input is attached to.
  34151. */
  34152. camera: ArcRotateCamera;
  34153. /**
  34154. * Defines the list of key codes associated with the up action (increase alpha)
  34155. */
  34156. keysUp: number[];
  34157. /**
  34158. * Defines the list of key codes associated with the down action (decrease alpha)
  34159. */
  34160. keysDown: number[];
  34161. /**
  34162. * Defines the list of key codes associated with the left action (increase beta)
  34163. */
  34164. keysLeft: number[];
  34165. /**
  34166. * Defines the list of key codes associated with the right action (decrease beta)
  34167. */
  34168. keysRight: number[];
  34169. /**
  34170. * Defines the list of key codes associated with the reset action.
  34171. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34172. */
  34173. keysReset: number[];
  34174. /**
  34175. * Defines the panning sensibility of the inputs.
  34176. * (How fast is the camera paning)
  34177. */
  34178. panningSensibility: number;
  34179. /**
  34180. * Defines the zooming sensibility of the inputs.
  34181. * (How fast is the camera zooming)
  34182. */
  34183. zoomingSensibility: number;
  34184. /**
  34185. * Defines wether maintaining the alt key down switch the movement mode from
  34186. * orientation to zoom.
  34187. */
  34188. useAltToZoom: boolean;
  34189. /**
  34190. * Rotation speed of the camera
  34191. */
  34192. angularSpeed: number;
  34193. private _keys;
  34194. private _ctrlPressed;
  34195. private _altPressed;
  34196. private _onCanvasBlurObserver;
  34197. private _onKeyboardObserver;
  34198. private _engine;
  34199. private _scene;
  34200. /**
  34201. * Attach the input controls to a specific dom element to get the input from.
  34202. * @param element Defines the element the controls should be listened from
  34203. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34204. */
  34205. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34206. /**
  34207. * Detach the current controls from the specified dom element.
  34208. * @param element Defines the element to stop listening the inputs from
  34209. */
  34210. detachControl(element: Nullable<HTMLElement>): void;
  34211. /**
  34212. * Update the current camera state depending on the inputs that have been used this frame.
  34213. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34214. */
  34215. checkInputs(): void;
  34216. /**
  34217. * Gets the class name of the current intput.
  34218. * @returns the class name
  34219. */
  34220. getClassName(): string;
  34221. /**
  34222. * Get the friendly name associated with the input class.
  34223. * @returns the input friendly name
  34224. */
  34225. getSimpleName(): string;
  34226. }
  34227. }
  34228. declare module BABYLON {
  34229. /**
  34230. * Manage the mouse wheel inputs to control an arc rotate camera.
  34231. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34232. */
  34233. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  34234. /**
  34235. * Defines the camera the input is attached to.
  34236. */
  34237. camera: ArcRotateCamera;
  34238. /**
  34239. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34240. */
  34241. wheelPrecision: number;
  34242. /**
  34243. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  34244. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  34245. */
  34246. wheelDeltaPercentage: number;
  34247. private _wheel;
  34248. private _observer;
  34249. /**
  34250. * Attach the input controls to a specific dom element to get the input from.
  34251. * @param element Defines the element the controls should be listened from
  34252. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34253. */
  34254. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34255. /**
  34256. * Detach the current controls from the specified dom element.
  34257. * @param element Defines the element to stop listening the inputs from
  34258. */
  34259. detachControl(element: Nullable<HTMLElement>): void;
  34260. /**
  34261. * Gets the class name of the current intput.
  34262. * @returns the class name
  34263. */
  34264. getClassName(): string;
  34265. /**
  34266. * Get the friendly name associated with the input class.
  34267. * @returns the input friendly name
  34268. */
  34269. getSimpleName(): string;
  34270. }
  34271. }
  34272. declare module BABYLON {
  34273. /**
  34274. * Default Inputs manager for the ArcRotateCamera.
  34275. * It groups all the default supported inputs for ease of use.
  34276. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34277. */
  34278. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  34279. /**
  34280. * Instantiates a new ArcRotateCameraInputsManager.
  34281. * @param camera Defines the camera the inputs belong to
  34282. */
  34283. constructor(camera: ArcRotateCamera);
  34284. /**
  34285. * Add mouse wheel input support to the input manager.
  34286. * @returns the current input manager
  34287. */
  34288. addMouseWheel(): ArcRotateCameraInputsManager;
  34289. /**
  34290. * Add pointers input support to the input manager.
  34291. * @returns the current input manager
  34292. */
  34293. addPointers(): ArcRotateCameraInputsManager;
  34294. /**
  34295. * Add keyboard input support to the input manager.
  34296. * @returns the current input manager
  34297. */
  34298. addKeyboard(): ArcRotateCameraInputsManager;
  34299. }
  34300. }
  34301. declare module BABYLON {
  34302. /**
  34303. * This represents an orbital type of camera.
  34304. *
  34305. * 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.
  34306. * 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.
  34307. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  34308. */
  34309. export class ArcRotateCamera extends TargetCamera {
  34310. /**
  34311. * Defines the rotation angle of the camera along the longitudinal axis.
  34312. */
  34313. alpha: number;
  34314. /**
  34315. * Defines the rotation angle of the camera along the latitudinal axis.
  34316. */
  34317. beta: number;
  34318. /**
  34319. * Defines the radius of the camera from it s target point.
  34320. */
  34321. radius: number;
  34322. protected _target: Vector3;
  34323. protected _targetHost: Nullable<AbstractMesh>;
  34324. /**
  34325. * Defines the target point of the camera.
  34326. * The camera looks towards it form the radius distance.
  34327. */
  34328. target: Vector3;
  34329. /**
  34330. * Define the current local position of the camera in the scene
  34331. */
  34332. position: Vector3;
  34333. protected _upVector: Vector3;
  34334. protected _upToYMatrix: Matrix;
  34335. protected _YToUpMatrix: Matrix;
  34336. /**
  34337. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  34338. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  34339. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  34340. */
  34341. upVector: Vector3;
  34342. /**
  34343. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  34344. */
  34345. setMatUp(): void;
  34346. /**
  34347. * Current inertia value on the longitudinal axis.
  34348. * The bigger this number the longer it will take for the camera to stop.
  34349. */
  34350. inertialAlphaOffset: number;
  34351. /**
  34352. * Current inertia value on the latitudinal axis.
  34353. * The bigger this number the longer it will take for the camera to stop.
  34354. */
  34355. inertialBetaOffset: number;
  34356. /**
  34357. * Current inertia value on the radius axis.
  34358. * The bigger this number the longer it will take for the camera to stop.
  34359. */
  34360. inertialRadiusOffset: number;
  34361. /**
  34362. * Minimum allowed angle on the longitudinal axis.
  34363. * This can help limiting how the Camera is able to move in the scene.
  34364. */
  34365. lowerAlphaLimit: Nullable<number>;
  34366. /**
  34367. * Maximum allowed angle on the longitudinal axis.
  34368. * This can help limiting how the Camera is able to move in the scene.
  34369. */
  34370. upperAlphaLimit: Nullable<number>;
  34371. /**
  34372. * Minimum allowed angle on the latitudinal axis.
  34373. * This can help limiting how the Camera is able to move in the scene.
  34374. */
  34375. lowerBetaLimit: number;
  34376. /**
  34377. * Maximum allowed angle on the latitudinal axis.
  34378. * This can help limiting how the Camera is able to move in the scene.
  34379. */
  34380. upperBetaLimit: number;
  34381. /**
  34382. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  34383. * This can help limiting how the Camera is able to move in the scene.
  34384. */
  34385. lowerRadiusLimit: Nullable<number>;
  34386. /**
  34387. * Maximum allowed distance of the camera to the target (The camera can not get further).
  34388. * This can help limiting how the Camera is able to move in the scene.
  34389. */
  34390. upperRadiusLimit: Nullable<number>;
  34391. /**
  34392. * Defines the current inertia value used during panning of the camera along the X axis.
  34393. */
  34394. inertialPanningX: number;
  34395. /**
  34396. * Defines the current inertia value used during panning of the camera along the Y axis.
  34397. */
  34398. inertialPanningY: number;
  34399. /**
  34400. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  34401. * Basically if your fingers moves away from more than this distance you will be considered
  34402. * in pinch mode.
  34403. */
  34404. pinchToPanMaxDistance: number;
  34405. /**
  34406. * Defines the maximum distance the camera can pan.
  34407. * This could help keeping the cammera always in your scene.
  34408. */
  34409. panningDistanceLimit: Nullable<number>;
  34410. /**
  34411. * Defines the target of the camera before paning.
  34412. */
  34413. panningOriginTarget: Vector3;
  34414. /**
  34415. * Defines the value of the inertia used during panning.
  34416. * 0 would mean stop inertia and one would mean no decelleration at all.
  34417. */
  34418. panningInertia: number;
  34419. /**
  34420. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34421. */
  34422. angularSensibilityX: number;
  34423. /**
  34424. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34425. */
  34426. angularSensibilityY: number;
  34427. /**
  34428. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  34429. */
  34430. pinchPrecision: number;
  34431. /**
  34432. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  34433. * It will be used instead of pinchDeltaPrecision if different from 0.
  34434. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34435. */
  34436. pinchDeltaPercentage: number;
  34437. /**
  34438. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  34439. */
  34440. panningSensibility: number;
  34441. /**
  34442. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  34443. */
  34444. keysUp: number[];
  34445. /**
  34446. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  34447. */
  34448. keysDown: number[];
  34449. /**
  34450. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  34451. */
  34452. keysLeft: number[];
  34453. /**
  34454. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  34455. */
  34456. keysRight: number[];
  34457. /**
  34458. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34459. */
  34460. wheelPrecision: number;
  34461. /**
  34462. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  34463. * It will be used instead of pinchDeltaPrecision if different from 0.
  34464. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34465. */
  34466. wheelDeltaPercentage: number;
  34467. /**
  34468. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  34469. */
  34470. zoomOnFactor: number;
  34471. /**
  34472. * Defines a screen offset for the camera position.
  34473. */
  34474. targetScreenOffset: Vector2;
  34475. /**
  34476. * Allows the camera to be completely reversed.
  34477. * If false the camera can not arrive upside down.
  34478. */
  34479. allowUpsideDown: boolean;
  34480. /**
  34481. * Define if double tap/click is used to restore the previously saved state of the camera.
  34482. */
  34483. useInputToRestoreState: boolean;
  34484. /** @hidden */ viewMatrix: Matrix;
  34485. /** @hidden */ useCtrlForPanning: boolean;
  34486. /** @hidden */ panningMouseButton: number;
  34487. /**
  34488. * Defines the input associated to the camera.
  34489. */
  34490. inputs: ArcRotateCameraInputsManager;
  34491. /** @hidden */ reset: () => void;
  34492. /**
  34493. * Defines the allowed panning axis.
  34494. */
  34495. panningAxis: Vector3;
  34496. protected _localDirection: Vector3;
  34497. protected _transformedDirection: Vector3;
  34498. private _bouncingBehavior;
  34499. /**
  34500. * Gets the bouncing behavior of the camera if it has been enabled.
  34501. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34502. */
  34503. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  34504. /**
  34505. * Defines if the bouncing behavior of the camera is enabled on the camera.
  34506. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34507. */
  34508. useBouncingBehavior: boolean;
  34509. private _framingBehavior;
  34510. /**
  34511. * Gets the framing behavior of the camera if it has been enabled.
  34512. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34513. */
  34514. readonly framingBehavior: Nullable<FramingBehavior>;
  34515. /**
  34516. * Defines if the framing behavior of the camera is enabled on the camera.
  34517. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34518. */
  34519. useFramingBehavior: boolean;
  34520. private _autoRotationBehavior;
  34521. /**
  34522. * Gets the auto rotation behavior of the camera if it has been enabled.
  34523. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34524. */
  34525. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  34526. /**
  34527. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  34528. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34529. */
  34530. useAutoRotationBehavior: boolean;
  34531. /**
  34532. * Observable triggered when the mesh target has been changed on the camera.
  34533. */
  34534. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  34535. /**
  34536. * Event raised when the camera is colliding with a mesh.
  34537. */
  34538. onCollide: (collidedMesh: AbstractMesh) => void;
  34539. /**
  34540. * Defines whether the camera should check collision with the objects oh the scene.
  34541. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  34542. */
  34543. checkCollisions: boolean;
  34544. /**
  34545. * Defines the collision radius of the camera.
  34546. * This simulates a sphere around the camera.
  34547. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  34548. */
  34549. collisionRadius: Vector3;
  34550. protected _collider: Collider;
  34551. protected _previousPosition: Vector3;
  34552. protected _collisionVelocity: Vector3;
  34553. protected _newPosition: Vector3;
  34554. protected _previousAlpha: number;
  34555. protected _previousBeta: number;
  34556. protected _previousRadius: number;
  34557. protected _collisionTriggered: boolean;
  34558. protected _targetBoundingCenter: Nullable<Vector3>;
  34559. private _computationVector;
  34560. /**
  34561. * Instantiates a new ArcRotateCamera in a given scene
  34562. * @param name Defines the name of the camera
  34563. * @param alpha Defines the camera rotation along the logitudinal axis
  34564. * @param beta Defines the camera rotation along the latitudinal axis
  34565. * @param radius Defines the camera distance from its target
  34566. * @param target Defines the camera target
  34567. * @param scene Defines the scene the camera belongs to
  34568. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  34569. */
  34570. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  34571. /** @hidden */ initCache(): void;
  34572. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  34573. protected _getTargetPosition(): Vector3;
  34574. private _storedAlpha;
  34575. private _storedBeta;
  34576. private _storedRadius;
  34577. private _storedTarget;
  34578. /**
  34579. * Stores the current state of the camera (alpha, beta, radius and target)
  34580. * @returns the camera itself
  34581. */
  34582. storeState(): Camera;
  34583. /**
  34584. * @hidden
  34585. * Restored camera state. You must call storeState() first
  34586. */ restoreStateValues(): boolean;
  34587. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  34588. /**
  34589. * Attached controls to the current camera.
  34590. * @param element Defines the element the controls should be listened from
  34591. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34592. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  34593. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  34594. */
  34595. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  34596. /**
  34597. * Detach the current controls from the camera.
  34598. * The camera will stop reacting to inputs.
  34599. * @param element Defines the element to stop listening the inputs from
  34600. */
  34601. detachControl(element: HTMLElement): void;
  34602. /** @hidden */ checkInputs(): void;
  34603. protected _checkLimits(): void;
  34604. /**
  34605. * Rebuilds angles (alpha, beta) and radius from the give position and target
  34606. */
  34607. rebuildAnglesAndRadius(): void;
  34608. /**
  34609. * Use a position to define the current camera related information like aplha, beta and radius
  34610. * @param position Defines the position to set the camera at
  34611. */
  34612. setPosition(position: Vector3): void;
  34613. /**
  34614. * Defines the target the camera should look at.
  34615. * This will automatically adapt alpha beta and radius to fit within the new target.
  34616. * @param target Defines the new target as a Vector or a mesh
  34617. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  34618. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  34619. */
  34620. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  34621. /** @hidden */ getViewMatrix(): Matrix;
  34622. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  34623. /**
  34624. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  34625. * @param meshes Defines the mesh to zoom on
  34626. * @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)
  34627. */
  34628. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  34629. /**
  34630. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  34631. * The target will be changed but the radius
  34632. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  34633. * @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)
  34634. */
  34635. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  34636. min: Vector3;
  34637. max: Vector3;
  34638. distance: number;
  34639. }, doNotUpdateMaxZ?: boolean): void;
  34640. /**
  34641. * @override
  34642. * Override Camera.createRigCamera
  34643. */
  34644. createRigCamera(name: string, cameraIndex: number): Camera;
  34645. /**
  34646. * @hidden
  34647. * @override
  34648. * Override Camera._updateRigCameras
  34649. */ updateRigCameras(): void;
  34650. /**
  34651. * Destroy the camera and release the current resources hold by it.
  34652. */
  34653. dispose(): void;
  34654. /**
  34655. * Gets the current object class name.
  34656. * @return the class name
  34657. */
  34658. getClassName(): string;
  34659. }
  34660. }
  34661. declare module BABYLON {
  34662. /**
  34663. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  34664. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34665. */
  34666. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  34667. /**
  34668. * Gets the name of the behavior.
  34669. */
  34670. readonly name: string;
  34671. private _zoomStopsAnimation;
  34672. private _idleRotationSpeed;
  34673. private _idleRotationWaitTime;
  34674. private _idleRotationSpinupTime;
  34675. /**
  34676. * Sets the flag that indicates if user zooming should stop animation.
  34677. */
  34678. /**
  34679. * Gets the flag that indicates if user zooming should stop animation.
  34680. */
  34681. zoomStopsAnimation: boolean;
  34682. /**
  34683. * Sets the default speed at which the camera rotates around the model.
  34684. */
  34685. /**
  34686. * Gets the default speed at which the camera rotates around the model.
  34687. */
  34688. idleRotationSpeed: number;
  34689. /**
  34690. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  34691. */
  34692. /**
  34693. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  34694. */
  34695. idleRotationWaitTime: number;
  34696. /**
  34697. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34698. */
  34699. /**
  34700. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34701. */
  34702. idleRotationSpinupTime: number;
  34703. /**
  34704. * Gets a value indicating if the camera is currently rotating because of this behavior
  34705. */
  34706. readonly rotationInProgress: boolean;
  34707. private _onPrePointerObservableObserver;
  34708. private _onAfterCheckInputsObserver;
  34709. private _attachedCamera;
  34710. private _isPointerDown;
  34711. private _lastFrameTime;
  34712. private _lastInteractionTime;
  34713. private _cameraRotationSpeed;
  34714. /**
  34715. * Initializes the behavior.
  34716. */
  34717. init(): void;
  34718. /**
  34719. * Attaches the behavior to its arc rotate camera.
  34720. * @param camera Defines the camera to attach the behavior to
  34721. */
  34722. attach(camera: ArcRotateCamera): void;
  34723. /**
  34724. * Detaches the behavior from its current arc rotate camera.
  34725. */
  34726. detach(): void;
  34727. /**
  34728. * Returns true if user is scrolling.
  34729. * @return true if user is scrolling.
  34730. */
  34731. private _userIsZooming;
  34732. private _lastFrameRadius;
  34733. private _shouldAnimationStopForInteraction;
  34734. /**
  34735. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34736. */
  34737. private _applyUserInteraction;
  34738. private _userIsMoving;
  34739. }
  34740. }
  34741. declare module BABYLON {
  34742. /**
  34743. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  34744. */
  34745. export class AttachToBoxBehavior implements Behavior<Mesh> {
  34746. private ui;
  34747. /**
  34748. * The name of the behavior
  34749. */
  34750. name: string;
  34751. /**
  34752. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  34753. */
  34754. distanceAwayFromFace: number;
  34755. /**
  34756. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  34757. */
  34758. distanceAwayFromBottomOfFace: number;
  34759. private _faceVectors;
  34760. private _target;
  34761. private _scene;
  34762. private _onRenderObserver;
  34763. private _tmpMatrix;
  34764. private _tmpVector;
  34765. /**
  34766. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  34767. * @param ui The transform node that should be attched to the mesh
  34768. */
  34769. constructor(ui: TransformNode);
  34770. /**
  34771. * Initializes the behavior
  34772. */
  34773. init(): void;
  34774. private _closestFace;
  34775. private _zeroVector;
  34776. private _lookAtTmpMatrix;
  34777. private _lookAtToRef;
  34778. /**
  34779. * Attaches the AttachToBoxBehavior to the passed in mesh
  34780. * @param target The mesh that the specified node will be attached to
  34781. */
  34782. attach(target: Mesh): void;
  34783. /**
  34784. * Detaches the behavior from the mesh
  34785. */
  34786. detach(): void;
  34787. }
  34788. }
  34789. declare module BABYLON {
  34790. /**
  34791. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  34792. */
  34793. export class FadeInOutBehavior implements Behavior<Mesh> {
  34794. /**
  34795. * Time in milliseconds to delay before fading in (Default: 0)
  34796. */
  34797. delay: number;
  34798. /**
  34799. * Time in milliseconds for the mesh to fade in (Default: 300)
  34800. */
  34801. fadeInTime: number;
  34802. private _millisecondsPerFrame;
  34803. private _hovered;
  34804. private _hoverValue;
  34805. private _ownerNode;
  34806. /**
  34807. * Instatiates the FadeInOutBehavior
  34808. */
  34809. constructor();
  34810. /**
  34811. * The name of the behavior
  34812. */
  34813. readonly name: string;
  34814. /**
  34815. * Initializes the behavior
  34816. */
  34817. init(): void;
  34818. /**
  34819. * Attaches the fade behavior on the passed in mesh
  34820. * @param ownerNode The mesh that will be faded in/out once attached
  34821. */
  34822. attach(ownerNode: Mesh): void;
  34823. /**
  34824. * Detaches the behavior from the mesh
  34825. */
  34826. detach(): void;
  34827. /**
  34828. * Triggers the mesh to begin fading in or out
  34829. * @param value if the object should fade in or out (true to fade in)
  34830. */
  34831. fadeIn(value: boolean): void;
  34832. private _update;
  34833. private _setAllVisibility;
  34834. }
  34835. }
  34836. declare module BABYLON {
  34837. /**
  34838. * Class containing a set of static utilities functions for managing Pivots
  34839. * @hidden
  34840. */
  34841. export class PivotTools {
  34842. private static _PivotCached;
  34843. private static _OldPivotPoint;
  34844. private static _PivotTranslation;
  34845. private static _PivotTmpVector;
  34846. /** @hidden */ private static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  34847. /** @hidden */ private static _RestorePivotPoint(mesh: AbstractMesh): void;
  34848. }
  34849. }
  34850. declare module BABYLON {
  34851. /**
  34852. * Class containing static functions to help procedurally build meshes
  34853. */
  34854. export class PlaneBuilder {
  34855. /**
  34856. * Creates a plane mesh
  34857. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  34858. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  34859. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  34860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34861. * * If you create a double-sided mesh, you can choose what parts of 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
  34862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34863. * @param name defines the name of the mesh
  34864. * @param options defines the options used to create the mesh
  34865. * @param scene defines the hosting scene
  34866. * @returns the plane mesh
  34867. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  34868. */
  34869. static CreatePlane(name: string, options: {
  34870. size?: number;
  34871. width?: number;
  34872. height?: number;
  34873. sideOrientation?: number;
  34874. frontUVs?: Vector4;
  34875. backUVs?: Vector4;
  34876. updatable?: boolean;
  34877. sourcePlane?: Plane;
  34878. }, scene?: Nullable<Scene>): Mesh;
  34879. }
  34880. }
  34881. declare module BABYLON {
  34882. /**
  34883. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  34884. */
  34885. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  34886. private static _AnyMouseID;
  34887. private _attachedNode;
  34888. private _dragPlane;
  34889. private _scene;
  34890. private _pointerObserver;
  34891. private _beforeRenderObserver;
  34892. private static _planeScene;
  34893. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  34894. /**
  34895. * 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)
  34896. */
  34897. maxDragAngle: number;
  34898. /**
  34899. * @hidden
  34900. */ useAlternatePickedPointAboveMaxDragAngle: boolean;
  34901. /**
  34902. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  34903. */
  34904. currentDraggingPointerID: number;
  34905. /**
  34906. * The last position where the pointer hit the drag plane in world space
  34907. */
  34908. lastDragPosition: Vector3;
  34909. /**
  34910. * If the behavior is currently in a dragging state
  34911. */
  34912. dragging: boolean;
  34913. /**
  34914. * 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)
  34915. */
  34916. dragDeltaRatio: number;
  34917. /**
  34918. * If the drag plane orientation should be updated during the dragging (Default: true)
  34919. */
  34920. updateDragPlane: boolean;
  34921. private _debugMode;
  34922. private _moving;
  34923. /**
  34924. * Fires each time the attached mesh is dragged with the pointer
  34925. * * delta between last drag position and current drag position in world space
  34926. * * dragDistance along the drag axis
  34927. * * dragPlaneNormal normal of the current drag plane used during the drag
  34928. * * dragPlanePoint in world space where the drag intersects the drag plane
  34929. */
  34930. onDragObservable: Observable<{
  34931. delta: Vector3;
  34932. dragPlanePoint: Vector3;
  34933. dragPlaneNormal: Vector3;
  34934. dragDistance: number;
  34935. pointerId: number;
  34936. }>;
  34937. /**
  34938. * Fires each time a drag begins (eg. mouse down on mesh)
  34939. */
  34940. onDragStartObservable: Observable<{
  34941. dragPlanePoint: Vector3;
  34942. pointerId: number;
  34943. }>;
  34944. /**
  34945. * Fires each time a drag ends (eg. mouse release after drag)
  34946. */
  34947. onDragEndObservable: Observable<{
  34948. dragPlanePoint: Vector3;
  34949. pointerId: number;
  34950. }>;
  34951. /**
  34952. * If the attached mesh should be moved when dragged
  34953. */
  34954. moveAttached: boolean;
  34955. /**
  34956. * If the drag behavior will react to drag events (Default: true)
  34957. */
  34958. enabled: boolean;
  34959. /**
  34960. * If camera controls should be detached during the drag
  34961. */
  34962. detachCameraControls: boolean;
  34963. /**
  34964. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  34965. */
  34966. useObjectOrienationForDragging: boolean;
  34967. private _options;
  34968. /**
  34969. * Creates a pointer drag behavior that can be attached to a mesh
  34970. * @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)
  34971. */
  34972. constructor(options?: {
  34973. dragAxis?: Vector3;
  34974. dragPlaneNormal?: Vector3;
  34975. });
  34976. /**
  34977. * Predicate to determine if it is valid to move the object to a new position when it is moved
  34978. */
  34979. validateDrag: (targetPosition: Vector3) => boolean;
  34980. /**
  34981. * The name of the behavior
  34982. */
  34983. readonly name: string;
  34984. /**
  34985. * Initializes the behavior
  34986. */
  34987. init(): void;
  34988. private _tmpVector;
  34989. private _alternatePickedPoint;
  34990. private _worldDragAxis;
  34991. private _targetPosition;
  34992. private _attachedElement;
  34993. /**
  34994. * Attaches the drag behavior the passed in mesh
  34995. * @param ownerNode The mesh that will be dragged around once attached
  34996. */
  34997. attach(ownerNode: AbstractMesh): void;
  34998. /**
  34999. * Force relase the drag action by code.
  35000. */
  35001. releaseDrag(): void;
  35002. private _startDragRay;
  35003. private _lastPointerRay;
  35004. /**
  35005. * Simulates the start of a pointer drag event on the behavior
  35006. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35007. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35008. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35009. */
  35010. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35011. private _startDrag;
  35012. private _dragDelta;
  35013. private _moveDrag;
  35014. private _pickWithRayOnDragPlane;
  35015. private _pointA;
  35016. private _pointB;
  35017. private _pointC;
  35018. private _lineA;
  35019. private _lineB;
  35020. private _localAxis;
  35021. private _lookAt;
  35022. private _updateDragPlanePosition;
  35023. /**
  35024. * Detaches the behavior from the mesh
  35025. */
  35026. detach(): void;
  35027. }
  35028. }
  35029. declare module BABYLON {
  35030. /**
  35031. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35032. */
  35033. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35034. private _dragBehaviorA;
  35035. private _dragBehaviorB;
  35036. private _startDistance;
  35037. private _initialScale;
  35038. private _targetScale;
  35039. private _ownerNode;
  35040. private _sceneRenderObserver;
  35041. /**
  35042. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35043. */
  35044. constructor();
  35045. /**
  35046. * The name of the behavior
  35047. */
  35048. readonly name: string;
  35049. /**
  35050. * Initializes the behavior
  35051. */
  35052. init(): void;
  35053. private _getCurrentDistance;
  35054. /**
  35055. * Attaches the scale behavior the passed in mesh
  35056. * @param ownerNode The mesh that will be scaled around once attached
  35057. */
  35058. attach(ownerNode: Mesh): void;
  35059. /**
  35060. * Detaches the behavior from the mesh
  35061. */
  35062. detach(): void;
  35063. }
  35064. }
  35065. declare module BABYLON {
  35066. /**
  35067. * 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
  35068. */
  35069. export class SixDofDragBehavior implements Behavior<Mesh> {
  35070. private static _virtualScene;
  35071. private _ownerNode;
  35072. private _sceneRenderObserver;
  35073. private _scene;
  35074. private _targetPosition;
  35075. private _virtualOriginMesh;
  35076. private _virtualDragMesh;
  35077. private _pointerObserver;
  35078. private _moving;
  35079. private _startingOrientation;
  35080. /**
  35081. * 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)
  35082. */
  35083. private zDragFactor;
  35084. /**
  35085. * If the object should rotate to face the drag origin
  35086. */
  35087. rotateDraggedObject: boolean;
  35088. /**
  35089. * If the behavior is currently in a dragging state
  35090. */
  35091. dragging: boolean;
  35092. /**
  35093. * 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)
  35094. */
  35095. dragDeltaRatio: number;
  35096. /**
  35097. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35098. */
  35099. currentDraggingPointerID: number;
  35100. /**
  35101. * If camera controls should be detached during the drag
  35102. */
  35103. detachCameraControls: boolean;
  35104. /**
  35105. * Fires each time a drag starts
  35106. */
  35107. onDragStartObservable: Observable<{}>;
  35108. /**
  35109. * Fires each time a drag ends (eg. mouse release after drag)
  35110. */
  35111. onDragEndObservable: Observable<{}>;
  35112. /**
  35113. * 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
  35114. */
  35115. constructor();
  35116. /**
  35117. * The name of the behavior
  35118. */
  35119. readonly name: string;
  35120. /**
  35121. * Initializes the behavior
  35122. */
  35123. init(): void;
  35124. /**
  35125. * Attaches the scale behavior the passed in mesh
  35126. * @param ownerNode The mesh that will be scaled around once attached
  35127. */
  35128. attach(ownerNode: Mesh): void;
  35129. /**
  35130. * Detaches the behavior from the mesh
  35131. */
  35132. detach(): void;
  35133. }
  35134. }
  35135. declare module BABYLON {
  35136. /**
  35137. * Class used to apply inverse kinematics to bones
  35138. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35139. */
  35140. export class BoneIKController {
  35141. private static _tmpVecs;
  35142. private static _tmpQuat;
  35143. private static _tmpMats;
  35144. /**
  35145. * Gets or sets the target mesh
  35146. */
  35147. targetMesh: AbstractMesh;
  35148. /** Gets or sets the mesh used as pole */
  35149. poleTargetMesh: AbstractMesh;
  35150. /**
  35151. * Gets or sets the bone used as pole
  35152. */
  35153. poleTargetBone: Nullable<Bone>;
  35154. /**
  35155. * Gets or sets the target position
  35156. */
  35157. targetPosition: Vector3;
  35158. /**
  35159. * Gets or sets the pole target position
  35160. */
  35161. poleTargetPosition: Vector3;
  35162. /**
  35163. * Gets or sets the pole target local offset
  35164. */
  35165. poleTargetLocalOffset: Vector3;
  35166. /**
  35167. * Gets or sets the pole angle
  35168. */
  35169. poleAngle: number;
  35170. /**
  35171. * Gets or sets the mesh associated with the controller
  35172. */
  35173. mesh: AbstractMesh;
  35174. /**
  35175. * 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)
  35176. */
  35177. slerpAmount: number;
  35178. private _bone1Quat;
  35179. private _bone1Mat;
  35180. private _bone2Ang;
  35181. private _bone1;
  35182. private _bone2;
  35183. private _bone1Length;
  35184. private _bone2Length;
  35185. private _maxAngle;
  35186. private _maxReach;
  35187. private _rightHandedSystem;
  35188. private _bendAxis;
  35189. private _slerping;
  35190. private _adjustRoll;
  35191. /**
  35192. * Gets or sets maximum allowed angle
  35193. */
  35194. maxAngle: number;
  35195. /**
  35196. * Creates a new BoneIKController
  35197. * @param mesh defines the mesh to control
  35198. * @param bone defines the bone to control
  35199. * @param options defines options to set up the controller
  35200. */
  35201. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  35202. targetMesh?: AbstractMesh;
  35203. poleTargetMesh?: AbstractMesh;
  35204. poleTargetBone?: Bone;
  35205. poleTargetLocalOffset?: Vector3;
  35206. poleAngle?: number;
  35207. bendAxis?: Vector3;
  35208. maxAngle?: number;
  35209. slerpAmount?: number;
  35210. });
  35211. private _setMaxAngle;
  35212. /**
  35213. * Force the controller to update the bones
  35214. */
  35215. update(): void;
  35216. }
  35217. }
  35218. declare module BABYLON {
  35219. /**
  35220. * Class used to make a bone look toward a point in space
  35221. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  35222. */
  35223. export class BoneLookController {
  35224. private static _tmpVecs;
  35225. private static _tmpQuat;
  35226. private static _tmpMats;
  35227. /**
  35228. * The target Vector3 that the bone will look at
  35229. */
  35230. target: Vector3;
  35231. /**
  35232. * The mesh that the bone is attached to
  35233. */
  35234. mesh: AbstractMesh;
  35235. /**
  35236. * The bone that will be looking to the target
  35237. */
  35238. bone: Bone;
  35239. /**
  35240. * The up axis of the coordinate system that is used when the bone is rotated
  35241. */
  35242. upAxis: Vector3;
  35243. /**
  35244. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  35245. */
  35246. upAxisSpace: Space;
  35247. /**
  35248. * Used to make an adjustment to the yaw of the bone
  35249. */
  35250. adjustYaw: number;
  35251. /**
  35252. * Used to make an adjustment to the pitch of the bone
  35253. */
  35254. adjustPitch: number;
  35255. /**
  35256. * Used to make an adjustment to the roll of the bone
  35257. */
  35258. adjustRoll: number;
  35259. /**
  35260. * 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)
  35261. */
  35262. slerpAmount: number;
  35263. private _minYaw;
  35264. private _maxYaw;
  35265. private _minPitch;
  35266. private _maxPitch;
  35267. private _minYawSin;
  35268. private _minYawCos;
  35269. private _maxYawSin;
  35270. private _maxYawCos;
  35271. private _midYawConstraint;
  35272. private _minPitchTan;
  35273. private _maxPitchTan;
  35274. private _boneQuat;
  35275. private _slerping;
  35276. private _transformYawPitch;
  35277. private _transformYawPitchInv;
  35278. private _firstFrameSkipped;
  35279. private _yawRange;
  35280. private _fowardAxis;
  35281. /**
  35282. * Gets or sets the minimum yaw angle that the bone can look to
  35283. */
  35284. minYaw: number;
  35285. /**
  35286. * Gets or sets the maximum yaw angle that the bone can look to
  35287. */
  35288. maxYaw: number;
  35289. /**
  35290. * Gets or sets the minimum pitch angle that the bone can look to
  35291. */
  35292. minPitch: number;
  35293. /**
  35294. * Gets or sets the maximum pitch angle that the bone can look to
  35295. */
  35296. maxPitch: number;
  35297. /**
  35298. * Create a BoneLookController
  35299. * @param mesh the mesh that the bone belongs to
  35300. * @param bone the bone that will be looking to the target
  35301. * @param target the target Vector3 to look at
  35302. * @param options optional settings:
  35303. * * maxYaw: the maximum angle the bone will yaw to
  35304. * * minYaw: the minimum angle the bone will yaw to
  35305. * * maxPitch: the maximum angle the bone will pitch to
  35306. * * minPitch: the minimum angle the bone will yaw to
  35307. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  35308. * * upAxis: the up axis of the coordinate system
  35309. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  35310. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  35311. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  35312. * * adjustYaw: used to make an adjustment to the yaw of the bone
  35313. * * adjustPitch: used to make an adjustment to the pitch of the bone
  35314. * * adjustRoll: used to make an adjustment to the roll of the bone
  35315. **/
  35316. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  35317. maxYaw?: number;
  35318. minYaw?: number;
  35319. maxPitch?: number;
  35320. minPitch?: number;
  35321. slerpAmount?: number;
  35322. upAxis?: Vector3;
  35323. upAxisSpace?: Space;
  35324. yawAxis?: Vector3;
  35325. pitchAxis?: Vector3;
  35326. adjustYaw?: number;
  35327. adjustPitch?: number;
  35328. adjustRoll?: number;
  35329. });
  35330. /**
  35331. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  35332. */
  35333. update(): void;
  35334. private _getAngleDiff;
  35335. private _getAngleBetween;
  35336. private _isAngleBetween;
  35337. }
  35338. }
  35339. declare module BABYLON {
  35340. /**
  35341. * Manage the gamepad inputs to control an arc rotate camera.
  35342. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35343. */
  35344. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  35345. /**
  35346. * Defines the camera the input is attached to.
  35347. */
  35348. camera: ArcRotateCamera;
  35349. /**
  35350. * Defines the gamepad the input is gathering event from.
  35351. */
  35352. gamepad: Nullable<Gamepad>;
  35353. /**
  35354. * Defines the gamepad rotation sensiblity.
  35355. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35356. */
  35357. gamepadRotationSensibility: number;
  35358. /**
  35359. * Defines the gamepad move sensiblity.
  35360. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35361. */
  35362. gamepadMoveSensibility: number;
  35363. private _onGamepadConnectedObserver;
  35364. private _onGamepadDisconnectedObserver;
  35365. /**
  35366. * Attach the input controls to a specific dom element to get the input from.
  35367. * @param element Defines the element the controls should be listened from
  35368. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35369. */
  35370. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35371. /**
  35372. * Detach the current controls from the specified dom element.
  35373. * @param element Defines the element to stop listening the inputs from
  35374. */
  35375. detachControl(element: Nullable<HTMLElement>): void;
  35376. /**
  35377. * Update the current camera state depending on the inputs that have been used this frame.
  35378. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35379. */
  35380. checkInputs(): void;
  35381. /**
  35382. * Gets the class name of the current intput.
  35383. * @returns the class name
  35384. */
  35385. getClassName(): string;
  35386. /**
  35387. * Get the friendly name associated with the input class.
  35388. * @returns the input friendly name
  35389. */
  35390. getSimpleName(): string;
  35391. }
  35392. }
  35393. declare module BABYLON {
  35394. interface ArcRotateCameraInputsManager {
  35395. /**
  35396. * Add orientation input support to the input manager.
  35397. * @returns the current input manager
  35398. */
  35399. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  35400. }
  35401. /**
  35402. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  35403. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35404. */
  35405. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  35406. /**
  35407. * Defines the camera the input is attached to.
  35408. */
  35409. camera: ArcRotateCamera;
  35410. /**
  35411. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  35412. */
  35413. alphaCorrection: number;
  35414. /**
  35415. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  35416. */
  35417. gammaCorrection: number;
  35418. private _alpha;
  35419. private _gamma;
  35420. private _dirty;
  35421. private _deviceOrientationHandler;
  35422. /**
  35423. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  35424. */
  35425. constructor();
  35426. /**
  35427. * Attach the input controls to a specific dom element to get the input from.
  35428. * @param element Defines the element the controls should be listened from
  35429. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35430. */
  35431. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35432. /** @hidden */ onOrientationEvent(evt: DeviceOrientationEvent): void;
  35433. /**
  35434. * Update the current camera state depending on the inputs that have been used this frame.
  35435. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35436. */
  35437. checkInputs(): void;
  35438. /**
  35439. * Detach the current controls from the specified dom element.
  35440. * @param element Defines the element to stop listening the inputs from
  35441. */
  35442. detachControl(element: Nullable<HTMLElement>): void;
  35443. /**
  35444. * Gets the class name of the current intput.
  35445. * @returns the class name
  35446. */
  35447. getClassName(): string;
  35448. /**
  35449. * Get the friendly name associated with the input class.
  35450. * @returns the input friendly name
  35451. */
  35452. getSimpleName(): string;
  35453. }
  35454. }
  35455. declare module BABYLON {
  35456. /**
  35457. * Listen to mouse events to control the camera.
  35458. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35459. */
  35460. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  35461. /**
  35462. * Defines the camera the input is attached to.
  35463. */
  35464. camera: FlyCamera;
  35465. /**
  35466. * Defines if touch is enabled. (Default is true.)
  35467. */
  35468. touchEnabled: boolean;
  35469. /**
  35470. * Defines the buttons associated with the input to handle camera rotation.
  35471. */
  35472. buttons: number[];
  35473. /**
  35474. * Assign buttons for Yaw control.
  35475. */
  35476. buttonsYaw: number[];
  35477. /**
  35478. * Assign buttons for Pitch control.
  35479. */
  35480. buttonsPitch: number[];
  35481. /**
  35482. * Assign buttons for Roll control.
  35483. */
  35484. buttonsRoll: number[];
  35485. /**
  35486. * Detect if any button is being pressed while mouse is moved.
  35487. * -1 = Mouse locked.
  35488. * 0 = Left button.
  35489. * 1 = Middle Button.
  35490. * 2 = Right Button.
  35491. */
  35492. activeButton: number;
  35493. /**
  35494. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  35495. * Higher values reduce its sensitivity.
  35496. */
  35497. angularSensibility: number;
  35498. private _mousemoveCallback;
  35499. private _observer;
  35500. private _rollObserver;
  35501. private previousPosition;
  35502. private noPreventDefault;
  35503. private element;
  35504. /**
  35505. * Listen to mouse events to control the camera.
  35506. * @param touchEnabled Define if touch is enabled. (Default is true.)
  35507. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35508. */
  35509. constructor(touchEnabled?: boolean);
  35510. /**
  35511. * Attach the mouse control to the HTML DOM element.
  35512. * @param element Defines the element that listens to the input events.
  35513. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  35514. */
  35515. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35516. /**
  35517. * Detach the current controls from the specified dom element.
  35518. * @param element Defines the element to stop listening the inputs from
  35519. */
  35520. detachControl(element: Nullable<HTMLElement>): void;
  35521. /**
  35522. * Gets the class name of the current input.
  35523. * @returns the class name.
  35524. */
  35525. getClassName(): string;
  35526. /**
  35527. * Get the friendly name associated with the input class.
  35528. * @returns the input's friendly name.
  35529. */
  35530. getSimpleName(): string;
  35531. private _pointerInput;
  35532. private _onMouseMove;
  35533. /**
  35534. * Rotate camera by mouse offset.
  35535. */
  35536. private rotateCamera;
  35537. }
  35538. }
  35539. declare module BABYLON {
  35540. /**
  35541. * Default Inputs manager for the FlyCamera.
  35542. * It groups all the default supported inputs for ease of use.
  35543. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35544. */
  35545. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  35546. /**
  35547. * Instantiates a new FlyCameraInputsManager.
  35548. * @param camera Defines the camera the inputs belong to.
  35549. */
  35550. constructor(camera: FlyCamera);
  35551. /**
  35552. * Add keyboard input support to the input manager.
  35553. * @returns the new FlyCameraKeyboardMoveInput().
  35554. */
  35555. addKeyboard(): FlyCameraInputsManager;
  35556. /**
  35557. * Add mouse input support to the input manager.
  35558. * @param touchEnabled Enable touch screen support.
  35559. * @returns the new FlyCameraMouseInput().
  35560. */
  35561. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  35562. }
  35563. }
  35564. declare module BABYLON {
  35565. /**
  35566. * This is a flying camera, designed for 3D movement and rotation in all directions,
  35567. * such as in a 3D Space Shooter or a Flight Simulator.
  35568. */
  35569. export class FlyCamera extends TargetCamera {
  35570. /**
  35571. * Define the collision ellipsoid of the camera.
  35572. * This is helpful for simulating a camera body, like a player's body.
  35573. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35574. */
  35575. ellipsoid: Vector3;
  35576. /**
  35577. * Define an offset for the position of the ellipsoid around the camera.
  35578. * This can be helpful if the camera is attached away from the player's body center,
  35579. * such as at its head.
  35580. */
  35581. ellipsoidOffset: Vector3;
  35582. /**
  35583. * Enable or disable collisions of the camera with the rest of the scene objects.
  35584. */
  35585. checkCollisions: boolean;
  35586. /**
  35587. * Enable or disable gravity on the camera.
  35588. */
  35589. applyGravity: boolean;
  35590. /**
  35591. * Define the current direction the camera is moving to.
  35592. */
  35593. cameraDirection: Vector3;
  35594. /**
  35595. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  35596. * This overrides and empties cameraRotation.
  35597. */
  35598. rotationQuaternion: Quaternion;
  35599. /**
  35600. * Track Roll to maintain the wanted Rolling when looking around.
  35601. */ trackRoll: number;
  35602. /**
  35603. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  35604. */
  35605. rollCorrect: number;
  35606. /**
  35607. * Mimic a banked turn, Rolling the camera when Yawing.
  35608. * It's recommended to use rollCorrect = 10 for faster banking correction.
  35609. */
  35610. bankedTurn: boolean;
  35611. /**
  35612. * Limit in radians for how much Roll banking will add. (Default: 90°)
  35613. */
  35614. bankedTurnLimit: number;
  35615. /**
  35616. * Value of 0 disables the banked Roll.
  35617. * Value of 1 is equal to the Yaw angle in radians.
  35618. */
  35619. bankedTurnMultiplier: number;
  35620. /**
  35621. * The inputs manager loads all the input sources, such as keyboard and mouse.
  35622. */
  35623. inputs: FlyCameraInputsManager;
  35624. /**
  35625. * Gets the input sensibility for mouse input.
  35626. * Higher values reduce sensitivity.
  35627. */
  35628. /**
  35629. * Sets the input sensibility for a mouse input.
  35630. * Higher values reduce sensitivity.
  35631. */
  35632. angularSensibility: number;
  35633. /**
  35634. * Get the keys for camera movement forward.
  35635. */
  35636. /**
  35637. * Set the keys for camera movement forward.
  35638. */
  35639. keysForward: number[];
  35640. /**
  35641. * Get the keys for camera movement backward.
  35642. */
  35643. keysBackward: number[];
  35644. /**
  35645. * Get the keys for camera movement up.
  35646. */
  35647. /**
  35648. * Set the keys for camera movement up.
  35649. */
  35650. keysUp: number[];
  35651. /**
  35652. * Get the keys for camera movement down.
  35653. */
  35654. /**
  35655. * Set the keys for camera movement down.
  35656. */
  35657. keysDown: number[];
  35658. /**
  35659. * Get the keys for camera movement left.
  35660. */
  35661. /**
  35662. * Set the keys for camera movement left.
  35663. */
  35664. keysLeft: number[];
  35665. /**
  35666. * Set the keys for camera movement right.
  35667. */
  35668. /**
  35669. * Set the keys for camera movement right.
  35670. */
  35671. keysRight: number[];
  35672. /**
  35673. * Event raised when the camera collides with a mesh in the scene.
  35674. */
  35675. onCollide: (collidedMesh: AbstractMesh) => void;
  35676. private _collider;
  35677. private _needMoveForGravity;
  35678. private _oldPosition;
  35679. private _diffPosition;
  35680. private _newPosition;
  35681. /** @hidden */ localDirection: Vector3;
  35682. /** @hidden */ transformedDirection: Vector3;
  35683. /**
  35684. * Instantiates a FlyCamera.
  35685. * This is a flying camera, designed for 3D movement and rotation in all directions,
  35686. * such as in a 3D Space Shooter or a Flight Simulator.
  35687. * @param name Define the name of the camera in the scene.
  35688. * @param position Define the starting position of the camera in the scene.
  35689. * @param scene Define the scene the camera belongs to.
  35690. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  35691. */
  35692. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35693. /**
  35694. * Attach a control to the HTML DOM element.
  35695. * @param element Defines the element that listens to the input events.
  35696. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  35697. */
  35698. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35699. /**
  35700. * Detach a control from the HTML DOM element.
  35701. * The camera will stop reacting to that input.
  35702. * @param element Defines the element that listens to the input events.
  35703. */
  35704. detachControl(element: HTMLElement): void;
  35705. private _collisionMask;
  35706. /**
  35707. * Get the mask that the camera ignores in collision events.
  35708. */
  35709. /**
  35710. * Set the mask that the camera ignores in collision events.
  35711. */
  35712. collisionMask: number;
  35713. /** @hidden */ collideWithWorld(displacement: Vector3): void;
  35714. /** @hidden */
  35715. private _onCollisionPositionChange;
  35716. /** @hidden */ checkInputs(): void;
  35717. /** @hidden */ decideIfNeedsToMove(): boolean;
  35718. /** @hidden */ updatePosition(): void;
  35719. /**
  35720. * Restore the Roll to its target value at the rate specified.
  35721. * @param rate - Higher means slower restoring.
  35722. * @hidden
  35723. */
  35724. restoreRoll(rate: number): void;
  35725. /**
  35726. * Destroy the camera and release the current resources held by it.
  35727. */
  35728. dispose(): void;
  35729. /**
  35730. * Get the current object class name.
  35731. * @returns the class name.
  35732. */
  35733. getClassName(): string;
  35734. }
  35735. }
  35736. declare module BABYLON {
  35737. /**
  35738. * Listen to keyboard events to control the camera.
  35739. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35740. */
  35741. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  35742. /**
  35743. * Defines the camera the input is attached to.
  35744. */
  35745. camera: FlyCamera;
  35746. /**
  35747. * The list of keyboard keys used to control the forward move of the camera.
  35748. */
  35749. keysForward: number[];
  35750. /**
  35751. * The list of keyboard keys used to control the backward move of the camera.
  35752. */
  35753. keysBackward: number[];
  35754. /**
  35755. * The list of keyboard keys used to control the forward move of the camera.
  35756. */
  35757. keysUp: number[];
  35758. /**
  35759. * The list of keyboard keys used to control the backward move of the camera.
  35760. */
  35761. keysDown: number[];
  35762. /**
  35763. * The list of keyboard keys used to control the right strafe move of the camera.
  35764. */
  35765. keysRight: number[];
  35766. /**
  35767. * The list of keyboard keys used to control the left strafe move of the camera.
  35768. */
  35769. keysLeft: number[];
  35770. private _keys;
  35771. private _onCanvasBlurObserver;
  35772. private _onKeyboardObserver;
  35773. private _engine;
  35774. private _scene;
  35775. /**
  35776. * Attach the input controls to a specific dom element to get the input from.
  35777. * @param element Defines the element the controls should be listened from
  35778. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35779. */
  35780. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35781. /**
  35782. * Detach the current controls from the specified dom element.
  35783. * @param element Defines the element to stop listening the inputs from
  35784. */
  35785. detachControl(element: Nullable<HTMLElement>): void;
  35786. /**
  35787. * Gets the class name of the current intput.
  35788. * @returns the class name
  35789. */
  35790. getClassName(): string;
  35791. /** @hidden */ onLostFocus(e: FocusEvent): void;
  35792. /**
  35793. * Get the friendly name associated with the input class.
  35794. * @returns the input friendly name
  35795. */
  35796. getSimpleName(): string;
  35797. /**
  35798. * Update the current camera state depending on the inputs that have been used this frame.
  35799. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35800. */
  35801. checkInputs(): void;
  35802. }
  35803. }
  35804. declare module BABYLON {
  35805. /**
  35806. * Manage the mouse wheel inputs to control a follow camera.
  35807. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35808. */
  35809. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  35810. /**
  35811. * Defines the camera the input is attached to.
  35812. */
  35813. camera: FollowCamera;
  35814. /**
  35815. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  35816. */
  35817. axisControlRadius: boolean;
  35818. /**
  35819. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  35820. */
  35821. axisControlHeight: boolean;
  35822. /**
  35823. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  35824. */
  35825. axisControlRotation: boolean;
  35826. /**
  35827. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  35828. * relation to mouseWheel events.
  35829. */
  35830. wheelPrecision: number;
  35831. /**
  35832. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35833. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35834. */
  35835. wheelDeltaPercentage: number;
  35836. private _wheel;
  35837. private _observer;
  35838. /**
  35839. * Attach the input controls to a specific dom element to get the input from.
  35840. * @param element Defines the element the controls should be listened from
  35841. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35842. */
  35843. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35844. /**
  35845. * Detach the current controls from the specified dom element.
  35846. * @param element Defines the element to stop listening the inputs from
  35847. */
  35848. detachControl(element: Nullable<HTMLElement>): void;
  35849. /**
  35850. * Gets the class name of the current intput.
  35851. * @returns the class name
  35852. */
  35853. getClassName(): string;
  35854. /**
  35855. * Get the friendly name associated with the input class.
  35856. * @returns the input friendly name
  35857. */
  35858. getSimpleName(): string;
  35859. }
  35860. }
  35861. declare module BABYLON {
  35862. /**
  35863. * Manage the pointers inputs to control an follow camera.
  35864. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35865. */
  35866. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  35867. /**
  35868. * Defines the camera the input is attached to.
  35869. */
  35870. camera: FollowCamera;
  35871. /**
  35872. * Gets the class name of the current input.
  35873. * @returns the class name
  35874. */
  35875. getClassName(): string;
  35876. /**
  35877. * Defines the pointer angular sensibility along the X axis or how fast is
  35878. * the camera rotating.
  35879. * A negative number will reverse the axis direction.
  35880. */
  35881. angularSensibilityX: number;
  35882. /**
  35883. * Defines the pointer angular sensibility along the Y axis or how fast is
  35884. * the camera rotating.
  35885. * A negative number will reverse the axis direction.
  35886. */
  35887. angularSensibilityY: number;
  35888. /**
  35889. * Defines the pointer pinch precision or how fast is the camera zooming.
  35890. * A negative number will reverse the axis direction.
  35891. */
  35892. pinchPrecision: number;
  35893. /**
  35894. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35895. * from 0.
  35896. * It defines the percentage of current camera.radius to use as delta when
  35897. * pinch zoom is used.
  35898. */
  35899. pinchDeltaPercentage: number;
  35900. /**
  35901. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  35902. */
  35903. axisXControlRadius: boolean;
  35904. /**
  35905. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  35906. */
  35907. axisXControlHeight: boolean;
  35908. /**
  35909. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  35910. */
  35911. axisXControlRotation: boolean;
  35912. /**
  35913. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  35914. */
  35915. axisYControlRadius: boolean;
  35916. /**
  35917. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  35918. */
  35919. axisYControlHeight: boolean;
  35920. /**
  35921. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  35922. */
  35923. axisYControlRotation: boolean;
  35924. /**
  35925. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  35926. */
  35927. axisPinchControlRadius: boolean;
  35928. /**
  35929. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  35930. */
  35931. axisPinchControlHeight: boolean;
  35932. /**
  35933. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  35934. */
  35935. axisPinchControlRotation: boolean;
  35936. /**
  35937. * Log error messages if basic misconfiguration has occurred.
  35938. */
  35939. warningEnable: boolean;
  35940. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35941. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35942. private _warningCounter;
  35943. private _warning;
  35944. }
  35945. }
  35946. declare module BABYLON {
  35947. /**
  35948. * Default Inputs manager for the FollowCamera.
  35949. * It groups all the default supported inputs for ease of use.
  35950. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35951. */
  35952. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  35953. /**
  35954. * Instantiates a new FollowCameraInputsManager.
  35955. * @param camera Defines the camera the inputs belong to
  35956. */
  35957. constructor(camera: FollowCamera);
  35958. /**
  35959. * Add keyboard input support to the input manager.
  35960. * @returns the current input manager
  35961. */
  35962. addKeyboard(): FollowCameraInputsManager;
  35963. /**
  35964. * Add mouse wheel input support to the input manager.
  35965. * @returns the current input manager
  35966. */
  35967. addMouseWheel(): FollowCameraInputsManager;
  35968. /**
  35969. * Add pointers input support to the input manager.
  35970. * @returns the current input manager
  35971. */
  35972. addPointers(): FollowCameraInputsManager;
  35973. /**
  35974. * Add orientation input support to the input manager.
  35975. * @returns the current input manager
  35976. */
  35977. addVRDeviceOrientation(): FollowCameraInputsManager;
  35978. }
  35979. }
  35980. declare module BABYLON {
  35981. /**
  35982. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  35983. * an arc rotate version arcFollowCamera are available.
  35984. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  35985. */
  35986. export class FollowCamera extends TargetCamera {
  35987. /**
  35988. * Distance the follow camera should follow an object at
  35989. */
  35990. radius: number;
  35991. /**
  35992. * Minimum allowed distance of the camera to the axis of rotation
  35993. * (The camera can not get closer).
  35994. * This can help limiting how the Camera is able to move in the scene.
  35995. */
  35996. lowerRadiusLimit: Nullable<number>;
  35997. /**
  35998. * Maximum allowed distance of the camera to the axis of rotation
  35999. * (The camera can not get further).
  36000. * This can help limiting how the Camera is able to move in the scene.
  36001. */
  36002. upperRadiusLimit: Nullable<number>;
  36003. /**
  36004. * Define a rotation offset between the camera and the object it follows
  36005. */
  36006. rotationOffset: number;
  36007. /**
  36008. * Minimum allowed angle to camera position relative to target object.
  36009. * This can help limiting how the Camera is able to move in the scene.
  36010. */
  36011. lowerRotationOffsetLimit: Nullable<number>;
  36012. /**
  36013. * Maximum allowed angle to camera position relative to target object.
  36014. * This can help limiting how the Camera is able to move in the scene.
  36015. */
  36016. upperRotationOffsetLimit: Nullable<number>;
  36017. /**
  36018. * Define a height offset between the camera and the object it follows.
  36019. * It can help following an object from the top (like a car chaing a plane)
  36020. */
  36021. heightOffset: number;
  36022. /**
  36023. * Minimum allowed height of camera position relative to target object.
  36024. * This can help limiting how the Camera is able to move in the scene.
  36025. */
  36026. lowerHeightOffsetLimit: Nullable<number>;
  36027. /**
  36028. * Maximum allowed height of camera position relative to target object.
  36029. * This can help limiting how the Camera is able to move in the scene.
  36030. */
  36031. upperHeightOffsetLimit: Nullable<number>;
  36032. /**
  36033. * Define how fast the camera can accelerate to follow it s target.
  36034. */
  36035. cameraAcceleration: number;
  36036. /**
  36037. * Define the speed limit of the camera following an object.
  36038. */
  36039. maxCameraSpeed: number;
  36040. /**
  36041. * Define the target of the camera.
  36042. */
  36043. lockedTarget: Nullable<AbstractMesh>;
  36044. /**
  36045. * Defines the input associated with the camera.
  36046. */
  36047. inputs: FollowCameraInputsManager;
  36048. /**
  36049. * Instantiates the follow camera.
  36050. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36051. * @param name Define the name of the camera in the scene
  36052. * @param position Define the position of the camera
  36053. * @param scene Define the scene the camera belong to
  36054. * @param lockedTarget Define the target of the camera
  36055. */
  36056. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36057. private _follow;
  36058. /**
  36059. * Attached controls to the current camera.
  36060. * @param element Defines the element the controls should be listened from
  36061. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36062. */
  36063. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36064. /**
  36065. * Detach the current controls from the camera.
  36066. * The camera will stop reacting to inputs.
  36067. * @param element Defines the element to stop listening the inputs from
  36068. */
  36069. detachControl(element: HTMLElement): void;
  36070. /** @hidden */ checkInputs(): void;
  36071. private _checkLimits;
  36072. /**
  36073. * Gets the camera class name.
  36074. * @returns the class name
  36075. */
  36076. getClassName(): string;
  36077. }
  36078. /**
  36079. * Arc Rotate version of the follow camera.
  36080. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36081. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36082. */
  36083. export class ArcFollowCamera extends TargetCamera {
  36084. /** The longitudinal angle of the camera */
  36085. alpha: number;
  36086. /** The latitudinal angle of the camera */
  36087. beta: number;
  36088. /** The radius of the camera from its target */
  36089. radius: number;
  36090. /** Define the camera target (the messh it should follow) */
  36091. target: Nullable<AbstractMesh>;
  36092. private _cartesianCoordinates;
  36093. /**
  36094. * Instantiates a new ArcFollowCamera
  36095. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36096. * @param name Define the name of the camera
  36097. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36098. * @param beta Define the rotation angle of the camera around the elevation axis
  36099. * @param radius Define the radius of the camera from its target point
  36100. * @param target Define the target of the camera
  36101. * @param scene Define the scene the camera belongs to
  36102. */
  36103. constructor(name: string,
  36104. /** The longitudinal angle of the camera */
  36105. alpha: number,
  36106. /** The latitudinal angle of the camera */
  36107. beta: number,
  36108. /** The radius of the camera from its target */
  36109. radius: number,
  36110. /** Define the camera target (the messh it should follow) */
  36111. target: Nullable<AbstractMesh>, scene: Scene);
  36112. private _follow;
  36113. /** @hidden */ checkInputs(): void;
  36114. /**
  36115. * Returns the class name of the object.
  36116. * It is mostly used internally for serialization purposes.
  36117. */
  36118. getClassName(): string;
  36119. }
  36120. }
  36121. declare module BABYLON {
  36122. /**
  36123. * Manage the keyboard inputs to control the movement of a follow camera.
  36124. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36125. */
  36126. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36127. /**
  36128. * Defines the camera the input is attached to.
  36129. */
  36130. camera: FollowCamera;
  36131. /**
  36132. * Defines the list of key codes associated with the up action (increase heightOffset)
  36133. */
  36134. keysHeightOffsetIncr: number[];
  36135. /**
  36136. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36137. */
  36138. keysHeightOffsetDecr: number[];
  36139. /**
  36140. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36141. */
  36142. keysHeightOffsetModifierAlt: boolean;
  36143. /**
  36144. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36145. */
  36146. keysHeightOffsetModifierCtrl: boolean;
  36147. /**
  36148. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36149. */
  36150. keysHeightOffsetModifierShift: boolean;
  36151. /**
  36152. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36153. */
  36154. keysRotationOffsetIncr: number[];
  36155. /**
  36156. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  36157. */
  36158. keysRotationOffsetDecr: number[];
  36159. /**
  36160. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  36161. */
  36162. keysRotationOffsetModifierAlt: boolean;
  36163. /**
  36164. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  36165. */
  36166. keysRotationOffsetModifierCtrl: boolean;
  36167. /**
  36168. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  36169. */
  36170. keysRotationOffsetModifierShift: boolean;
  36171. /**
  36172. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  36173. */
  36174. keysRadiusIncr: number[];
  36175. /**
  36176. * Defines the list of key codes associated with the zoom-out action (increase radius)
  36177. */
  36178. keysRadiusDecr: number[];
  36179. /**
  36180. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  36181. */
  36182. keysRadiusModifierAlt: boolean;
  36183. /**
  36184. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  36185. */
  36186. keysRadiusModifierCtrl: boolean;
  36187. /**
  36188. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  36189. */
  36190. keysRadiusModifierShift: boolean;
  36191. /**
  36192. * Defines the rate of change of heightOffset.
  36193. */
  36194. heightSensibility: number;
  36195. /**
  36196. * Defines the rate of change of rotationOffset.
  36197. */
  36198. rotationSensibility: number;
  36199. /**
  36200. * Defines the rate of change of radius.
  36201. */
  36202. radiusSensibility: number;
  36203. private _keys;
  36204. private _ctrlPressed;
  36205. private _altPressed;
  36206. private _shiftPressed;
  36207. private _onCanvasBlurObserver;
  36208. private _onKeyboardObserver;
  36209. private _engine;
  36210. private _scene;
  36211. /**
  36212. * Attach the input controls to a specific dom element to get the input from.
  36213. * @param element Defines the element the controls should be listened from
  36214. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36215. */
  36216. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36217. /**
  36218. * Detach the current controls from the specified dom element.
  36219. * @param element Defines the element to stop listening the inputs from
  36220. */
  36221. detachControl(element: Nullable<HTMLElement>): void;
  36222. /**
  36223. * Update the current camera state depending on the inputs that have been used this frame.
  36224. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36225. */
  36226. checkInputs(): void;
  36227. /**
  36228. * Gets the class name of the current input.
  36229. * @returns the class name
  36230. */
  36231. getClassName(): string;
  36232. /**
  36233. * Get the friendly name associated with the input class.
  36234. * @returns the input friendly name
  36235. */
  36236. getSimpleName(): string;
  36237. /**
  36238. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36239. * allow modification of the heightOffset value.
  36240. */
  36241. private _modifierHeightOffset;
  36242. /**
  36243. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36244. * allow modification of the rotationOffset value.
  36245. */
  36246. private _modifierRotationOffset;
  36247. /**
  36248. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36249. * allow modification of the radius value.
  36250. */
  36251. private _modifierRadius;
  36252. }
  36253. }
  36254. declare module BABYLON {
  36255. interface FreeCameraInputsManager {
  36256. /**
  36257. * @hidden
  36258. */ deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  36259. /**
  36260. * Add orientation input support to the input manager.
  36261. * @returns the current input manager
  36262. */
  36263. addDeviceOrientation(): FreeCameraInputsManager;
  36264. }
  36265. /**
  36266. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  36267. * Screen rotation is taken into account.
  36268. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36269. */
  36270. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  36271. private _camera;
  36272. private _screenOrientationAngle;
  36273. private _constantTranform;
  36274. private _screenQuaternion;
  36275. private _alpha;
  36276. private _beta;
  36277. private _gamma;
  36278. /**
  36279. * @hidden
  36280. */ onDeviceOrientationChangedObservable: Observable<void>;
  36281. /**
  36282. * Instantiates a new input
  36283. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36284. */
  36285. constructor();
  36286. /**
  36287. * Define the camera controlled by the input.
  36288. */
  36289. camera: FreeCamera;
  36290. /**
  36291. * Attach the input controls to a specific dom element to get the input from.
  36292. * @param element Defines the element the controls should be listened from
  36293. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36294. */
  36295. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36296. private _orientationChanged;
  36297. private _deviceOrientation;
  36298. /**
  36299. * Detach the current controls from the specified dom element.
  36300. * @param element Defines the element to stop listening the inputs from
  36301. */
  36302. detachControl(element: Nullable<HTMLElement>): void;
  36303. /**
  36304. * Update the current camera state depending on the inputs that have been used this frame.
  36305. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36306. */
  36307. checkInputs(): void;
  36308. /**
  36309. * Gets the class name of the current intput.
  36310. * @returns the class name
  36311. */
  36312. getClassName(): string;
  36313. /**
  36314. * Get the friendly name associated with the input class.
  36315. * @returns the input friendly name
  36316. */
  36317. getSimpleName(): string;
  36318. }
  36319. }
  36320. declare module BABYLON {
  36321. /**
  36322. * Manage the gamepad inputs to control a free camera.
  36323. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36324. */
  36325. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  36326. /**
  36327. * Define the camera the input is attached to.
  36328. */
  36329. camera: FreeCamera;
  36330. /**
  36331. * Define the Gamepad controlling the input
  36332. */
  36333. gamepad: Nullable<Gamepad>;
  36334. /**
  36335. * Defines the gamepad rotation sensiblity.
  36336. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36337. */
  36338. gamepadAngularSensibility: number;
  36339. /**
  36340. * Defines the gamepad move sensiblity.
  36341. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36342. */
  36343. gamepadMoveSensibility: number;
  36344. private _onGamepadConnectedObserver;
  36345. private _onGamepadDisconnectedObserver;
  36346. private _cameraTransform;
  36347. private _deltaTransform;
  36348. private _vector3;
  36349. private _vector2;
  36350. /**
  36351. * Attach the input controls to a specific dom element to get the input from.
  36352. * @param element Defines the element the controls should be listened from
  36353. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36354. */
  36355. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36356. /**
  36357. * Detach the current controls from the specified dom element.
  36358. * @param element Defines the element to stop listening the inputs from
  36359. */
  36360. detachControl(element: Nullable<HTMLElement>): void;
  36361. /**
  36362. * Update the current camera state depending on the inputs that have been used this frame.
  36363. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36364. */
  36365. checkInputs(): void;
  36366. /**
  36367. * Gets the class name of the current intput.
  36368. * @returns the class name
  36369. */
  36370. getClassName(): string;
  36371. /**
  36372. * Get the friendly name associated with the input class.
  36373. * @returns the input friendly name
  36374. */
  36375. getSimpleName(): string;
  36376. }
  36377. }
  36378. declare module BABYLON {
  36379. /**
  36380. * Defines the potential axis of a Joystick
  36381. */
  36382. export enum JoystickAxis {
  36383. /** X axis */
  36384. X = 0,
  36385. /** Y axis */
  36386. Y = 1,
  36387. /** Z axis */
  36388. Z = 2
  36389. }
  36390. /**
  36391. * Class used to define virtual joystick (used in touch mode)
  36392. */
  36393. export class VirtualJoystick {
  36394. /**
  36395. * Gets or sets a boolean indicating that left and right values must be inverted
  36396. */
  36397. reverseLeftRight: boolean;
  36398. /**
  36399. * Gets or sets a boolean indicating that up and down values must be inverted
  36400. */
  36401. reverseUpDown: boolean;
  36402. /**
  36403. * Gets the offset value for the position (ie. the change of the position value)
  36404. */
  36405. deltaPosition: Vector3;
  36406. /**
  36407. * Gets a boolean indicating if the virtual joystick was pressed
  36408. */
  36409. pressed: boolean;
  36410. /**
  36411. * Canvas the virtual joystick will render onto, default z-index of this is 5
  36412. */
  36413. static Canvas: Nullable<HTMLCanvasElement>;
  36414. private static _globalJoystickIndex;
  36415. private static vjCanvasContext;
  36416. private static vjCanvasWidth;
  36417. private static vjCanvasHeight;
  36418. private static halfWidth;
  36419. private _action;
  36420. private _axisTargetedByLeftAndRight;
  36421. private _axisTargetedByUpAndDown;
  36422. private _joystickSensibility;
  36423. private _inversedSensibility;
  36424. private _joystickPointerID;
  36425. private _joystickColor;
  36426. private _joystickPointerPos;
  36427. private _joystickPreviousPointerPos;
  36428. private _joystickPointerStartPos;
  36429. private _deltaJoystickVector;
  36430. private _leftJoystick;
  36431. private _touches;
  36432. private _onPointerDownHandlerRef;
  36433. private _onPointerMoveHandlerRef;
  36434. private _onPointerUpHandlerRef;
  36435. private _onResize;
  36436. /**
  36437. * Creates a new virtual joystick
  36438. * @param leftJoystick defines that the joystick is for left hand (false by default)
  36439. */
  36440. constructor(leftJoystick?: boolean);
  36441. /**
  36442. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  36443. * @param newJoystickSensibility defines the new sensibility
  36444. */
  36445. setJoystickSensibility(newJoystickSensibility: number): void;
  36446. private _onPointerDown;
  36447. private _onPointerMove;
  36448. private _onPointerUp;
  36449. /**
  36450. * Change the color of the virtual joystick
  36451. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  36452. */
  36453. setJoystickColor(newColor: string): void;
  36454. /**
  36455. * Defines a callback to call when the joystick is touched
  36456. * @param action defines the callback
  36457. */
  36458. setActionOnTouch(action: () => any): void;
  36459. /**
  36460. * Defines which axis you'd like to control for left & right
  36461. * @param axis defines the axis to use
  36462. */
  36463. setAxisForLeftRight(axis: JoystickAxis): void;
  36464. /**
  36465. * Defines which axis you'd like to control for up & down
  36466. * @param axis defines the axis to use
  36467. */
  36468. setAxisForUpDown(axis: JoystickAxis): void;
  36469. private _drawVirtualJoystick;
  36470. /**
  36471. * Release internal HTML canvas
  36472. */
  36473. releaseCanvas(): void;
  36474. }
  36475. }
  36476. declare module BABYLON {
  36477. interface FreeCameraInputsManager {
  36478. /**
  36479. * Add virtual joystick input support to the input manager.
  36480. * @returns the current input manager
  36481. */
  36482. addVirtualJoystick(): FreeCameraInputsManager;
  36483. }
  36484. /**
  36485. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  36486. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36487. */
  36488. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  36489. /**
  36490. * Defines the camera the input is attached to.
  36491. */
  36492. camera: FreeCamera;
  36493. private _leftjoystick;
  36494. private _rightjoystick;
  36495. /**
  36496. * Gets the left stick of the virtual joystick.
  36497. * @returns The virtual Joystick
  36498. */
  36499. getLeftJoystick(): VirtualJoystick;
  36500. /**
  36501. * Gets the right stick of the virtual joystick.
  36502. * @returns The virtual Joystick
  36503. */
  36504. getRightJoystick(): VirtualJoystick;
  36505. /**
  36506. * Update the current camera state depending on the inputs that have been used this frame.
  36507. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36508. */
  36509. checkInputs(): void;
  36510. /**
  36511. * Attach the input controls to a specific dom element to get the input from.
  36512. * @param element Defines the element the controls should be listened from
  36513. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36514. */
  36515. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36516. /**
  36517. * Detach the current controls from the specified dom element.
  36518. * @param element Defines the element to stop listening the inputs from
  36519. */
  36520. detachControl(element: Nullable<HTMLElement>): void;
  36521. /**
  36522. * Gets the class name of the current intput.
  36523. * @returns the class name
  36524. */
  36525. getClassName(): string;
  36526. /**
  36527. * Get the friendly name associated with the input class.
  36528. * @returns the input friendly name
  36529. */
  36530. getSimpleName(): string;
  36531. }
  36532. }
  36533. declare module BABYLON {
  36534. /**
  36535. * This represents a FPS type of camera controlled by touch.
  36536. * This is like a universal camera minus the Gamepad controls.
  36537. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36538. */
  36539. export class TouchCamera extends FreeCamera {
  36540. /**
  36541. * Defines the touch sensibility for rotation.
  36542. * The higher the faster.
  36543. */
  36544. touchAngularSensibility: number;
  36545. /**
  36546. * Defines the touch sensibility for move.
  36547. * The higher the faster.
  36548. */
  36549. touchMoveSensibility: number;
  36550. /**
  36551. * Instantiates a new touch camera.
  36552. * This represents a FPS type of camera controlled by touch.
  36553. * This is like a universal camera minus the Gamepad controls.
  36554. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36555. * @param name Define the name of the camera in the scene
  36556. * @param position Define the start position of the camera in the scene
  36557. * @param scene Define the scene the camera belongs to
  36558. */
  36559. constructor(name: string, position: Vector3, scene: Scene);
  36560. /**
  36561. * Gets the current object class name.
  36562. * @return the class name
  36563. */
  36564. getClassName(): string;
  36565. /** @hidden */ setupInputs(): void;
  36566. }
  36567. }
  36568. declare module BABYLON {
  36569. /**
  36570. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  36571. * being tilted forward or back and left or right.
  36572. */
  36573. export class DeviceOrientationCamera extends FreeCamera {
  36574. private _initialQuaternion;
  36575. private _quaternionCache;
  36576. private _tmpDragQuaternion;
  36577. /**
  36578. * Creates a new device orientation camera
  36579. * @param name The name of the camera
  36580. * @param position The start position camera
  36581. * @param scene The scene the camera belongs to
  36582. */
  36583. constructor(name: string, position: Vector3, scene: Scene);
  36584. /**
  36585. * Disabled pointer input on first orientation sensor update (Default: true)
  36586. */
  36587. disablePointerInputWhenUsingDeviceOrientation: boolean;
  36588. private _dragFactor;
  36589. /**
  36590. * Enabled turning on the y axis when the orientation sensor is active
  36591. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  36592. */
  36593. enableHorizontalDragging(dragFactor?: number): void;
  36594. /**
  36595. * Gets the current instance class name ("DeviceOrientationCamera").
  36596. * This helps avoiding instanceof at run time.
  36597. * @returns the class name
  36598. */
  36599. getClassName(): string;
  36600. /**
  36601. * @hidden
  36602. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  36603. */ checkInputs(): void;
  36604. /**
  36605. * Reset the camera to its default orientation on the specified axis only.
  36606. * @param axis The axis to reset
  36607. */
  36608. resetToCurrentRotation(axis?: Axis): void;
  36609. }
  36610. }
  36611. declare module BABYLON {
  36612. /**
  36613. * 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,
  36614. * which still works and will still be found in many Playgrounds.
  36615. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36616. */
  36617. export class UniversalCamera extends TouchCamera {
  36618. /**
  36619. * Defines the gamepad rotation sensiblity.
  36620. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36621. */
  36622. gamepadAngularSensibility: number;
  36623. /**
  36624. * Defines the gamepad move sensiblity.
  36625. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36626. */
  36627. gamepadMoveSensibility: number;
  36628. /**
  36629. * 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,
  36630. * which still works and will still be found in many Playgrounds.
  36631. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36632. * @param name Define the name of the camera in the scene
  36633. * @param position Define the start position of the camera in the scene
  36634. * @param scene Define the scene the camera belongs to
  36635. */
  36636. constructor(name: string, position: Vector3, scene: Scene);
  36637. /**
  36638. * Gets the current object class name.
  36639. * @return the class name
  36640. */
  36641. getClassName(): string;
  36642. }
  36643. }
  36644. declare module BABYLON {
  36645. /**
  36646. * This represents a FPS type of camera. This is only here for back compat purpose.
  36647. * Please use the UniversalCamera instead as both are identical.
  36648. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36649. */
  36650. export class GamepadCamera extends UniversalCamera {
  36651. /**
  36652. * Instantiates a new Gamepad Camera
  36653. * This represents a FPS type of camera. This is only here for back compat purpose.
  36654. * Please use the UniversalCamera instead as both are identical.
  36655. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36656. * @param name Define the name of the camera in the scene
  36657. * @param position Define the start position of the camera in the scene
  36658. * @param scene Define the scene the camera belongs to
  36659. */
  36660. constructor(name: string, position: Vector3, scene: Scene);
  36661. /**
  36662. * Gets the current object class name.
  36663. * @return the class name
  36664. */
  36665. getClassName(): string;
  36666. }
  36667. }
  36668. declare module BABYLON {
  36669. /** @hidden */
  36670. export var passPixelShader: {
  36671. name: string;
  36672. shader: string;
  36673. };
  36674. }
  36675. declare module BABYLON {
  36676. /** @hidden */
  36677. export var passCubePixelShader: {
  36678. name: string;
  36679. shader: string;
  36680. };
  36681. }
  36682. declare module BABYLON {
  36683. /**
  36684. * PassPostProcess which produces an output the same as it's input
  36685. */
  36686. export class PassPostProcess extends PostProcess {
  36687. /**
  36688. * Creates the PassPostProcess
  36689. * @param name The name of the effect.
  36690. * @param options The required width/height ratio to downsize to before computing the render pass.
  36691. * @param camera The camera to apply the render pass to.
  36692. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36693. * @param engine The engine which the post process will be applied. (default: current engine)
  36694. * @param reusable If the post process can be reused on the same frame. (default: false)
  36695. * @param textureType The type of texture to be used when performing the post processing.
  36696. * @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)
  36697. */
  36698. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36699. }
  36700. /**
  36701. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  36702. */
  36703. export class PassCubePostProcess extends PostProcess {
  36704. private _face;
  36705. /**
  36706. * Gets or sets the cube face to display.
  36707. * * 0 is +X
  36708. * * 1 is -X
  36709. * * 2 is +Y
  36710. * * 3 is -Y
  36711. * * 4 is +Z
  36712. * * 5 is -Z
  36713. */
  36714. face: number;
  36715. /**
  36716. * Creates the PassCubePostProcess
  36717. * @param name The name of the effect.
  36718. * @param options The required width/height ratio to downsize to before computing the render pass.
  36719. * @param camera The camera to apply the render pass to.
  36720. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36721. * @param engine The engine which the post process will be applied. (default: current engine)
  36722. * @param reusable If the post process can be reused on the same frame. (default: false)
  36723. * @param textureType The type of texture to be used when performing the post processing.
  36724. * @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)
  36725. */
  36726. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36727. }
  36728. }
  36729. declare module BABYLON {
  36730. /** @hidden */
  36731. export var anaglyphPixelShader: {
  36732. name: string;
  36733. shader: string;
  36734. };
  36735. }
  36736. declare module BABYLON {
  36737. /**
  36738. * Postprocess used to generate anaglyphic rendering
  36739. */
  36740. export class AnaglyphPostProcess extends PostProcess {
  36741. private _passedProcess;
  36742. /**
  36743. * Creates a new AnaglyphPostProcess
  36744. * @param name defines postprocess name
  36745. * @param options defines creation options or target ratio scale
  36746. * @param rigCameras defines cameras using this postprocess
  36747. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  36748. * @param engine defines hosting engine
  36749. * @param reusable defines if the postprocess will be reused multiple times per frame
  36750. */
  36751. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  36752. }
  36753. }
  36754. declare module BABYLON {
  36755. /**
  36756. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  36757. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36758. */
  36759. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  36760. /**
  36761. * Creates a new AnaglyphArcRotateCamera
  36762. * @param name defines camera name
  36763. * @param alpha defines alpha angle (in radians)
  36764. * @param beta defines beta angle (in radians)
  36765. * @param radius defines radius
  36766. * @param target defines camera target
  36767. * @param interaxialDistance defines distance between each color axis
  36768. * @param scene defines the hosting scene
  36769. */
  36770. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  36771. /**
  36772. * Gets camera class name
  36773. * @returns AnaglyphArcRotateCamera
  36774. */
  36775. getClassName(): string;
  36776. }
  36777. }
  36778. declare module BABYLON {
  36779. /**
  36780. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  36781. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36782. */
  36783. export class AnaglyphFreeCamera extends FreeCamera {
  36784. /**
  36785. * Creates a new AnaglyphFreeCamera
  36786. * @param name defines camera name
  36787. * @param position defines initial position
  36788. * @param interaxialDistance defines distance between each color axis
  36789. * @param scene defines the hosting scene
  36790. */
  36791. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36792. /**
  36793. * Gets camera class name
  36794. * @returns AnaglyphFreeCamera
  36795. */
  36796. getClassName(): string;
  36797. }
  36798. }
  36799. declare module BABYLON {
  36800. /**
  36801. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  36802. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36803. */
  36804. export class AnaglyphGamepadCamera extends GamepadCamera {
  36805. /**
  36806. * Creates a new AnaglyphGamepadCamera
  36807. * @param name defines camera name
  36808. * @param position defines initial position
  36809. * @param interaxialDistance defines distance between each color axis
  36810. * @param scene defines the hosting scene
  36811. */
  36812. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36813. /**
  36814. * Gets camera class name
  36815. * @returns AnaglyphGamepadCamera
  36816. */
  36817. getClassName(): string;
  36818. }
  36819. }
  36820. declare module BABYLON {
  36821. /**
  36822. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  36823. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36824. */
  36825. export class AnaglyphUniversalCamera extends UniversalCamera {
  36826. /**
  36827. * Creates a new AnaglyphUniversalCamera
  36828. * @param name defines camera name
  36829. * @param position defines initial position
  36830. * @param interaxialDistance defines distance between each color axis
  36831. * @param scene defines the hosting scene
  36832. */
  36833. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36834. /**
  36835. * Gets camera class name
  36836. * @returns AnaglyphUniversalCamera
  36837. */
  36838. getClassName(): string;
  36839. }
  36840. }
  36841. declare module BABYLON {
  36842. /** @hidden */
  36843. export var stereoscopicInterlacePixelShader: {
  36844. name: string;
  36845. shader: string;
  36846. };
  36847. }
  36848. declare module BABYLON {
  36849. /**
  36850. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  36851. */
  36852. export class StereoscopicInterlacePostProcess extends PostProcess {
  36853. private _stepSize;
  36854. private _passedProcess;
  36855. /**
  36856. * Initializes a StereoscopicInterlacePostProcess
  36857. * @param name The name of the effect.
  36858. * @param rigCameras The rig cameras to be appled to the post process
  36859. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  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. */
  36864. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36865. }
  36866. }
  36867. declare module BABYLON {
  36868. /**
  36869. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  36870. * @see http://doc.babylonjs.com/features/cameras
  36871. */
  36872. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  36873. /**
  36874. * Creates a new StereoscopicArcRotateCamera
  36875. * @param name defines camera name
  36876. * @param alpha defines alpha angle (in radians)
  36877. * @param beta defines beta angle (in radians)
  36878. * @param radius defines radius
  36879. * @param target defines camera target
  36880. * @param interaxialDistance defines distance between each color axis
  36881. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36882. * @param scene defines the hosting scene
  36883. */
  36884. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36885. /**
  36886. * Gets camera class name
  36887. * @returns StereoscopicArcRotateCamera
  36888. */
  36889. getClassName(): string;
  36890. }
  36891. }
  36892. declare module BABYLON {
  36893. /**
  36894. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  36895. * @see http://doc.babylonjs.com/features/cameras
  36896. */
  36897. export class StereoscopicFreeCamera extends FreeCamera {
  36898. /**
  36899. * Creates a new StereoscopicFreeCamera
  36900. * @param name defines camera name
  36901. * @param position defines initial position
  36902. * @param interaxialDistance defines distance between each color axis
  36903. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36904. * @param scene defines the hosting scene
  36905. */
  36906. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36907. /**
  36908. * Gets camera class name
  36909. * @returns StereoscopicFreeCamera
  36910. */
  36911. getClassName(): string;
  36912. }
  36913. }
  36914. declare module BABYLON {
  36915. /**
  36916. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  36917. * @see http://doc.babylonjs.com/features/cameras
  36918. */
  36919. export class StereoscopicGamepadCamera extends GamepadCamera {
  36920. /**
  36921. * Creates a new StereoscopicGamepadCamera
  36922. * @param name defines camera name
  36923. * @param position defines initial position
  36924. * @param interaxialDistance defines distance between each color axis
  36925. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36926. * @param scene defines the hosting scene
  36927. */
  36928. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36929. /**
  36930. * Gets camera class name
  36931. * @returns StereoscopicGamepadCamera
  36932. */
  36933. getClassName(): string;
  36934. }
  36935. }
  36936. declare module BABYLON {
  36937. /**
  36938. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  36939. * @see http://doc.babylonjs.com/features/cameras
  36940. */
  36941. export class StereoscopicUniversalCamera extends UniversalCamera {
  36942. /**
  36943. * Creates a new StereoscopicUniversalCamera
  36944. * @param name defines camera name
  36945. * @param position defines initial position
  36946. * @param interaxialDistance defines distance between each color axis
  36947. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36948. * @param scene defines the hosting scene
  36949. */
  36950. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36951. /**
  36952. * Gets camera class name
  36953. * @returns StereoscopicUniversalCamera
  36954. */
  36955. getClassName(): string;
  36956. }
  36957. }
  36958. declare module BABYLON {
  36959. /**
  36960. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  36961. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  36962. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  36963. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  36964. */
  36965. export class VirtualJoysticksCamera extends FreeCamera {
  36966. /**
  36967. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  36968. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  36969. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  36970. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  36971. * @param name Define the name of the camera in the scene
  36972. * @param position Define the start position of the camera in the scene
  36973. * @param scene Define the scene the camera belongs to
  36974. */
  36975. constructor(name: string, position: Vector3, scene: Scene);
  36976. /**
  36977. * Gets the current object class name.
  36978. * @return the class name
  36979. */
  36980. getClassName(): string;
  36981. }
  36982. }
  36983. declare module BABYLON {
  36984. /**
  36985. * This represents all the required metrics to create a VR camera.
  36986. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  36987. */
  36988. export class VRCameraMetrics {
  36989. /**
  36990. * Define the horizontal resolution off the screen.
  36991. */
  36992. hResolution: number;
  36993. /**
  36994. * Define the vertical resolution off the screen.
  36995. */
  36996. vResolution: number;
  36997. /**
  36998. * Define the horizontal screen size.
  36999. */
  37000. hScreenSize: number;
  37001. /**
  37002. * Define the vertical screen size.
  37003. */
  37004. vScreenSize: number;
  37005. /**
  37006. * Define the vertical screen center position.
  37007. */
  37008. vScreenCenter: number;
  37009. /**
  37010. * Define the distance of the eyes to the screen.
  37011. */
  37012. eyeToScreenDistance: number;
  37013. /**
  37014. * Define the distance between both lenses
  37015. */
  37016. lensSeparationDistance: number;
  37017. /**
  37018. * Define the distance between both viewer's eyes.
  37019. */
  37020. interpupillaryDistance: number;
  37021. /**
  37022. * Define the distortion factor of the VR postprocess.
  37023. * Please, touch with care.
  37024. */
  37025. distortionK: number[];
  37026. /**
  37027. * Define the chromatic aberration correction factors for the VR post process.
  37028. */
  37029. chromaAbCorrection: number[];
  37030. /**
  37031. * Define the scale factor of the post process.
  37032. * The smaller the better but the slower.
  37033. */
  37034. postProcessScaleFactor: number;
  37035. /**
  37036. * Define an offset for the lens center.
  37037. */
  37038. lensCenterOffset: number;
  37039. /**
  37040. * Define if the current vr camera should compensate the distortion of the lense or not.
  37041. */
  37042. compensateDistortion: boolean;
  37043. /**
  37044. * Defines if multiview should be enabled when rendering (Default: false)
  37045. */
  37046. multiviewEnabled: boolean;
  37047. /**
  37048. * Gets the rendering aspect ratio based on the provided resolutions.
  37049. */
  37050. readonly aspectRatio: number;
  37051. /**
  37052. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  37053. */
  37054. readonly aspectRatioFov: number;
  37055. /**
  37056. * @hidden
  37057. */
  37058. readonly leftHMatrix: Matrix;
  37059. /**
  37060. * @hidden
  37061. */
  37062. readonly rightHMatrix: Matrix;
  37063. /**
  37064. * @hidden
  37065. */
  37066. readonly leftPreViewMatrix: Matrix;
  37067. /**
  37068. * @hidden
  37069. */
  37070. readonly rightPreViewMatrix: Matrix;
  37071. /**
  37072. * Get the default VRMetrics based on the most generic setup.
  37073. * @returns the default vr metrics
  37074. */
  37075. static GetDefault(): VRCameraMetrics;
  37076. }
  37077. }
  37078. declare module BABYLON {
  37079. /** @hidden */
  37080. export var vrDistortionCorrectionPixelShader: {
  37081. name: string;
  37082. shader: string;
  37083. };
  37084. }
  37085. declare module BABYLON {
  37086. /**
  37087. * VRDistortionCorrectionPostProcess used for mobile VR
  37088. */
  37089. export class VRDistortionCorrectionPostProcess extends PostProcess {
  37090. private _isRightEye;
  37091. private _distortionFactors;
  37092. private _postProcessScaleFactor;
  37093. private _lensCenterOffset;
  37094. private _scaleIn;
  37095. private _scaleFactor;
  37096. private _lensCenter;
  37097. /**
  37098. * Initializes the VRDistortionCorrectionPostProcess
  37099. * @param name The name of the effect.
  37100. * @param camera The camera to apply the render pass to.
  37101. * @param isRightEye If this is for the right eye distortion
  37102. * @param vrMetrics All the required metrics for the VR camera
  37103. */
  37104. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  37105. }
  37106. }
  37107. declare module BABYLON {
  37108. /**
  37109. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  37110. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37111. */
  37112. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  37113. /**
  37114. * Creates a new VRDeviceOrientationArcRotateCamera
  37115. * @param name defines camera name
  37116. * @param alpha defines the camera rotation along the logitudinal axis
  37117. * @param beta defines the camera rotation along the latitudinal axis
  37118. * @param radius defines the camera distance from its target
  37119. * @param target defines the camera target
  37120. * @param scene defines the scene the camera belongs to
  37121. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37122. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37123. */
  37124. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37125. /**
  37126. * Gets camera class name
  37127. * @returns VRDeviceOrientationArcRotateCamera
  37128. */
  37129. getClassName(): string;
  37130. }
  37131. }
  37132. declare module BABYLON {
  37133. /**
  37134. * Camera used to simulate VR rendering (based on FreeCamera)
  37135. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37136. */
  37137. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  37138. /**
  37139. * Creates a new VRDeviceOrientationFreeCamera
  37140. * @param name defines camera name
  37141. * @param position defines the start position of the camera
  37142. * @param scene defines the scene the camera belongs to
  37143. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37144. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37145. */
  37146. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37147. /**
  37148. * Gets camera class name
  37149. * @returns VRDeviceOrientationFreeCamera
  37150. */
  37151. getClassName(): string;
  37152. }
  37153. }
  37154. declare module BABYLON {
  37155. /**
  37156. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  37157. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37158. */
  37159. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  37160. /**
  37161. * Creates a new VRDeviceOrientationGamepadCamera
  37162. * @param name defines camera name
  37163. * @param position defines the start position of the camera
  37164. * @param scene defines the scene the camera belongs to
  37165. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37166. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37167. */
  37168. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37169. /**
  37170. * Gets camera class name
  37171. * @returns VRDeviceOrientationGamepadCamera
  37172. */
  37173. getClassName(): string;
  37174. }
  37175. }
  37176. declare module BABYLON {
  37177. /**
  37178. * Defines supported buttons for XBox360 compatible gamepads
  37179. */
  37180. export enum Xbox360Button {
  37181. /** A */
  37182. A = 0,
  37183. /** B */
  37184. B = 1,
  37185. /** X */
  37186. X = 2,
  37187. /** Y */
  37188. Y = 3,
  37189. /** Start */
  37190. Start = 4,
  37191. /** Back */
  37192. Back = 5,
  37193. /** Left button */
  37194. LB = 6,
  37195. /** Right button */
  37196. RB = 7,
  37197. /** Left stick */
  37198. LeftStick = 8,
  37199. /** Right stick */
  37200. RightStick = 9
  37201. }
  37202. /** Defines values for XBox360 DPad */
  37203. export enum Xbox360Dpad {
  37204. /** Up */
  37205. Up = 0,
  37206. /** Down */
  37207. Down = 1,
  37208. /** Left */
  37209. Left = 2,
  37210. /** Right */
  37211. Right = 3
  37212. }
  37213. /**
  37214. * Defines a XBox360 gamepad
  37215. */
  37216. export class Xbox360Pad extends Gamepad {
  37217. private _leftTrigger;
  37218. private _rightTrigger;
  37219. private _onlefttriggerchanged;
  37220. private _onrighttriggerchanged;
  37221. private _onbuttondown;
  37222. private _onbuttonup;
  37223. private _ondpaddown;
  37224. private _ondpadup;
  37225. /** Observable raised when a button is pressed */
  37226. onButtonDownObservable: Observable<Xbox360Button>;
  37227. /** Observable raised when a button is released */
  37228. onButtonUpObservable: Observable<Xbox360Button>;
  37229. /** Observable raised when a pad is pressed */
  37230. onPadDownObservable: Observable<Xbox360Dpad>;
  37231. /** Observable raised when a pad is released */
  37232. onPadUpObservable: Observable<Xbox360Dpad>;
  37233. private _buttonA;
  37234. private _buttonB;
  37235. private _buttonX;
  37236. private _buttonY;
  37237. private _buttonBack;
  37238. private _buttonStart;
  37239. private _buttonLB;
  37240. private _buttonRB;
  37241. private _buttonLeftStick;
  37242. private _buttonRightStick;
  37243. private _dPadUp;
  37244. private _dPadDown;
  37245. private _dPadLeft;
  37246. private _dPadRight;
  37247. private _isXboxOnePad;
  37248. /**
  37249. * Creates a new XBox360 gamepad object
  37250. * @param id defines the id of this gamepad
  37251. * @param index defines its index
  37252. * @param gamepad defines the internal HTML gamepad object
  37253. * @param xboxOne defines if it is a XBox One gamepad
  37254. */
  37255. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37256. /**
  37257. * Defines the callback to call when left trigger is pressed
  37258. * @param callback defines the callback to use
  37259. */
  37260. onlefttriggerchanged(callback: (value: number) => void): void;
  37261. /**
  37262. * Defines the callback to call when right trigger is pressed
  37263. * @param callback defines the callback to use
  37264. */
  37265. onrighttriggerchanged(callback: (value: number) => void): void;
  37266. /**
  37267. * Gets the left trigger value
  37268. */
  37269. /**
  37270. * Sets the left trigger value
  37271. */
  37272. leftTrigger: number;
  37273. /**
  37274. * Gets the right trigger value
  37275. */
  37276. /**
  37277. * Sets the right trigger value
  37278. */
  37279. rightTrigger: number;
  37280. /**
  37281. * Defines the callback to call when a button is pressed
  37282. * @param callback defines the callback to use
  37283. */
  37284. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37285. /**
  37286. * Defines the callback to call when a button is released
  37287. * @param callback defines the callback to use
  37288. */
  37289. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37290. /**
  37291. * Defines the callback to call when a pad is pressed
  37292. * @param callback defines the callback to use
  37293. */
  37294. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37295. /**
  37296. * Defines the callback to call when a pad is released
  37297. * @param callback defines the callback to use
  37298. */
  37299. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37300. private _setButtonValue;
  37301. private _setDPadValue;
  37302. /**
  37303. * Gets the value of the `A` button
  37304. */
  37305. /**
  37306. * Sets the value of the `A` button
  37307. */
  37308. buttonA: number;
  37309. /**
  37310. * Gets the value of the `B` button
  37311. */
  37312. /**
  37313. * Sets the value of the `B` button
  37314. */
  37315. buttonB: number;
  37316. /**
  37317. * Gets the value of the `X` button
  37318. */
  37319. /**
  37320. * Sets the value of the `X` button
  37321. */
  37322. buttonX: number;
  37323. /**
  37324. * Gets the value of the `Y` button
  37325. */
  37326. /**
  37327. * Sets the value of the `Y` button
  37328. */
  37329. buttonY: number;
  37330. /**
  37331. * Gets the value of the `Start` button
  37332. */
  37333. /**
  37334. * Sets the value of the `Start` button
  37335. */
  37336. buttonStart: number;
  37337. /**
  37338. * Gets the value of the `Back` button
  37339. */
  37340. /**
  37341. * Sets the value of the `Back` button
  37342. */
  37343. buttonBack: number;
  37344. /**
  37345. * Gets the value of the `Left` button
  37346. */
  37347. /**
  37348. * Sets the value of the `Left` button
  37349. */
  37350. buttonLB: number;
  37351. /**
  37352. * Gets the value of the `Right` button
  37353. */
  37354. /**
  37355. * Sets the value of the `Right` button
  37356. */
  37357. buttonRB: number;
  37358. /**
  37359. * Gets the value of the Left joystick
  37360. */
  37361. /**
  37362. * Sets the value of the Left joystick
  37363. */
  37364. buttonLeftStick: number;
  37365. /**
  37366. * Gets the value of the Right joystick
  37367. */
  37368. /**
  37369. * Sets the value of the Right joystick
  37370. */
  37371. buttonRightStick: number;
  37372. /**
  37373. * Gets the value of D-pad up
  37374. */
  37375. /**
  37376. * Sets the value of D-pad up
  37377. */
  37378. dPadUp: number;
  37379. /**
  37380. * Gets the value of D-pad down
  37381. */
  37382. /**
  37383. * Sets the value of D-pad down
  37384. */
  37385. dPadDown: number;
  37386. /**
  37387. * Gets the value of D-pad left
  37388. */
  37389. /**
  37390. * Sets the value of D-pad left
  37391. */
  37392. dPadLeft: number;
  37393. /**
  37394. * Gets the value of D-pad right
  37395. */
  37396. /**
  37397. * Sets the value of D-pad right
  37398. */
  37399. dPadRight: number;
  37400. /**
  37401. * Force the gamepad to synchronize with device values
  37402. */
  37403. update(): void;
  37404. /**
  37405. * Disposes the gamepad
  37406. */
  37407. dispose(): void;
  37408. }
  37409. }
  37410. declare module BABYLON {
  37411. /**
  37412. * Base class of materials working in push mode in babylon JS
  37413. * @hidden
  37414. */
  37415. export class PushMaterial extends Material {
  37416. protected _activeEffect: Effect;
  37417. protected _normalMatrix: Matrix;
  37418. /**
  37419. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  37420. * This means that the material can keep using a previous shader while a new one is being compiled.
  37421. * This is mostly used when shader parallel compilation is supported (true by default)
  37422. */
  37423. allowShaderHotSwapping: boolean;
  37424. constructor(name: string, scene: Scene);
  37425. getEffect(): Effect;
  37426. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  37427. /**
  37428. * Binds the given world matrix to the active effect
  37429. *
  37430. * @param world the matrix to bind
  37431. */
  37432. bindOnlyWorldMatrix(world: Matrix): void;
  37433. /**
  37434. * Binds the given normal matrix to the active effect
  37435. *
  37436. * @param normalMatrix the matrix to bind
  37437. */
  37438. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  37439. bind(world: Matrix, mesh?: Mesh): void;
  37440. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  37441. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  37442. }
  37443. }
  37444. declare module BABYLON {
  37445. /**
  37446. * This groups all the flags used to control the materials channel.
  37447. */
  37448. export class MaterialFlags {
  37449. private static _DiffuseTextureEnabled;
  37450. /**
  37451. * Are diffuse textures enabled in the application.
  37452. */
  37453. static DiffuseTextureEnabled: boolean;
  37454. private static _AmbientTextureEnabled;
  37455. /**
  37456. * Are ambient textures enabled in the application.
  37457. */
  37458. static AmbientTextureEnabled: boolean;
  37459. private static _OpacityTextureEnabled;
  37460. /**
  37461. * Are opacity textures enabled in the application.
  37462. */
  37463. static OpacityTextureEnabled: boolean;
  37464. private static _ReflectionTextureEnabled;
  37465. /**
  37466. * Are reflection textures enabled in the application.
  37467. */
  37468. static ReflectionTextureEnabled: boolean;
  37469. private static _EmissiveTextureEnabled;
  37470. /**
  37471. * Are emissive textures enabled in the application.
  37472. */
  37473. static EmissiveTextureEnabled: boolean;
  37474. private static _SpecularTextureEnabled;
  37475. /**
  37476. * Are specular textures enabled in the application.
  37477. */
  37478. static SpecularTextureEnabled: boolean;
  37479. private static _BumpTextureEnabled;
  37480. /**
  37481. * Are bump textures enabled in the application.
  37482. */
  37483. static BumpTextureEnabled: boolean;
  37484. private static _LightmapTextureEnabled;
  37485. /**
  37486. * Are lightmap textures enabled in the application.
  37487. */
  37488. static LightmapTextureEnabled: boolean;
  37489. private static _RefractionTextureEnabled;
  37490. /**
  37491. * Are refraction textures enabled in the application.
  37492. */
  37493. static RefractionTextureEnabled: boolean;
  37494. private static _ColorGradingTextureEnabled;
  37495. /**
  37496. * Are color grading textures enabled in the application.
  37497. */
  37498. static ColorGradingTextureEnabled: boolean;
  37499. private static _FresnelEnabled;
  37500. /**
  37501. * Are fresnels enabled in the application.
  37502. */
  37503. static FresnelEnabled: boolean;
  37504. private static _ClearCoatTextureEnabled;
  37505. /**
  37506. * Are clear coat textures enabled in the application.
  37507. */
  37508. static ClearCoatTextureEnabled: boolean;
  37509. private static _ClearCoatBumpTextureEnabled;
  37510. /**
  37511. * Are clear coat bump textures enabled in the application.
  37512. */
  37513. static ClearCoatBumpTextureEnabled: boolean;
  37514. private static _ClearCoatTintTextureEnabled;
  37515. /**
  37516. * Are clear coat tint textures enabled in the application.
  37517. */
  37518. static ClearCoatTintTextureEnabled: boolean;
  37519. private static _SheenTextureEnabled;
  37520. /**
  37521. * Are sheen textures enabled in the application.
  37522. */
  37523. static SheenTextureEnabled: boolean;
  37524. private static _AnisotropicTextureEnabled;
  37525. /**
  37526. * Are anisotropic textures enabled in the application.
  37527. */
  37528. static AnisotropicTextureEnabled: boolean;
  37529. private static _ThicknessTextureEnabled;
  37530. /**
  37531. * Are thickness textures enabled in the application.
  37532. */
  37533. static ThicknessTextureEnabled: boolean;
  37534. }
  37535. }
  37536. declare module BABYLON {
  37537. /** @hidden */
  37538. export var defaultFragmentDeclaration: {
  37539. name: string;
  37540. shader: string;
  37541. };
  37542. }
  37543. declare module BABYLON {
  37544. /** @hidden */
  37545. export var defaultUboDeclaration: {
  37546. name: string;
  37547. shader: string;
  37548. };
  37549. }
  37550. declare module BABYLON {
  37551. /** @hidden */
  37552. export var lightFragmentDeclaration: {
  37553. name: string;
  37554. shader: string;
  37555. };
  37556. }
  37557. declare module BABYLON {
  37558. /** @hidden */
  37559. export var lightUboDeclaration: {
  37560. name: string;
  37561. shader: string;
  37562. };
  37563. }
  37564. declare module BABYLON {
  37565. /** @hidden */
  37566. export var lightsFragmentFunctions: {
  37567. name: string;
  37568. shader: string;
  37569. };
  37570. }
  37571. declare module BABYLON {
  37572. /** @hidden */
  37573. export var shadowsFragmentFunctions: {
  37574. name: string;
  37575. shader: string;
  37576. };
  37577. }
  37578. declare module BABYLON {
  37579. /** @hidden */
  37580. export var fresnelFunction: {
  37581. name: string;
  37582. shader: string;
  37583. };
  37584. }
  37585. declare module BABYLON {
  37586. /** @hidden */
  37587. export var reflectionFunction: {
  37588. name: string;
  37589. shader: string;
  37590. };
  37591. }
  37592. declare module BABYLON {
  37593. /** @hidden */
  37594. export var bumpFragmentFunctions: {
  37595. name: string;
  37596. shader: string;
  37597. };
  37598. }
  37599. declare module BABYLON {
  37600. /** @hidden */
  37601. export var logDepthDeclaration: {
  37602. name: string;
  37603. shader: string;
  37604. };
  37605. }
  37606. declare module BABYLON {
  37607. /** @hidden */
  37608. export var bumpFragment: {
  37609. name: string;
  37610. shader: string;
  37611. };
  37612. }
  37613. declare module BABYLON {
  37614. /** @hidden */
  37615. export var depthPrePass: {
  37616. name: string;
  37617. shader: string;
  37618. };
  37619. }
  37620. declare module BABYLON {
  37621. /** @hidden */
  37622. export var lightFragment: {
  37623. name: string;
  37624. shader: string;
  37625. };
  37626. }
  37627. declare module BABYLON {
  37628. /** @hidden */
  37629. export var logDepthFragment: {
  37630. name: string;
  37631. shader: string;
  37632. };
  37633. }
  37634. declare module BABYLON {
  37635. /** @hidden */
  37636. export var defaultPixelShader: {
  37637. name: string;
  37638. shader: string;
  37639. };
  37640. }
  37641. declare module BABYLON {
  37642. /** @hidden */
  37643. export var defaultVertexDeclaration: {
  37644. name: string;
  37645. shader: string;
  37646. };
  37647. }
  37648. declare module BABYLON {
  37649. /** @hidden */
  37650. export var bumpVertexDeclaration: {
  37651. name: string;
  37652. shader: string;
  37653. };
  37654. }
  37655. declare module BABYLON {
  37656. /** @hidden */
  37657. export var bumpVertex: {
  37658. name: string;
  37659. shader: string;
  37660. };
  37661. }
  37662. declare module BABYLON {
  37663. /** @hidden */
  37664. export var fogVertex: {
  37665. name: string;
  37666. shader: string;
  37667. };
  37668. }
  37669. declare module BABYLON {
  37670. /** @hidden */
  37671. export var shadowsVertex: {
  37672. name: string;
  37673. shader: string;
  37674. };
  37675. }
  37676. declare module BABYLON {
  37677. /** @hidden */
  37678. export var pointCloudVertex: {
  37679. name: string;
  37680. shader: string;
  37681. };
  37682. }
  37683. declare module BABYLON {
  37684. /** @hidden */
  37685. export var logDepthVertex: {
  37686. name: string;
  37687. shader: string;
  37688. };
  37689. }
  37690. declare module BABYLON {
  37691. /** @hidden */
  37692. export var defaultVertexShader: {
  37693. name: string;
  37694. shader: string;
  37695. };
  37696. }
  37697. declare module BABYLON {
  37698. /** @hidden */
  37699. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  37700. MAINUV1: boolean;
  37701. MAINUV2: boolean;
  37702. DIFFUSE: boolean;
  37703. DIFFUSEDIRECTUV: number;
  37704. AMBIENT: boolean;
  37705. AMBIENTDIRECTUV: number;
  37706. OPACITY: boolean;
  37707. OPACITYDIRECTUV: number;
  37708. OPACITYRGB: boolean;
  37709. REFLECTION: boolean;
  37710. EMISSIVE: boolean;
  37711. EMISSIVEDIRECTUV: number;
  37712. SPECULAR: boolean;
  37713. SPECULARDIRECTUV: number;
  37714. BUMP: boolean;
  37715. BUMPDIRECTUV: number;
  37716. PARALLAX: boolean;
  37717. PARALLAXOCCLUSION: boolean;
  37718. SPECULAROVERALPHA: boolean;
  37719. CLIPPLANE: boolean;
  37720. CLIPPLANE2: boolean;
  37721. CLIPPLANE3: boolean;
  37722. CLIPPLANE4: boolean;
  37723. ALPHATEST: boolean;
  37724. DEPTHPREPASS: boolean;
  37725. ALPHAFROMDIFFUSE: boolean;
  37726. POINTSIZE: boolean;
  37727. FOG: boolean;
  37728. SPECULARTERM: boolean;
  37729. DIFFUSEFRESNEL: boolean;
  37730. OPACITYFRESNEL: boolean;
  37731. REFLECTIONFRESNEL: boolean;
  37732. REFRACTIONFRESNEL: boolean;
  37733. EMISSIVEFRESNEL: boolean;
  37734. FRESNEL: boolean;
  37735. NORMAL: boolean;
  37736. UV1: boolean;
  37737. UV2: boolean;
  37738. VERTEXCOLOR: boolean;
  37739. VERTEXALPHA: boolean;
  37740. NUM_BONE_INFLUENCERS: number;
  37741. BonesPerMesh: number;
  37742. BONETEXTURE: boolean;
  37743. INSTANCES: boolean;
  37744. GLOSSINESS: boolean;
  37745. ROUGHNESS: boolean;
  37746. EMISSIVEASILLUMINATION: boolean;
  37747. LINKEMISSIVEWITHDIFFUSE: boolean;
  37748. REFLECTIONFRESNELFROMSPECULAR: boolean;
  37749. LIGHTMAP: boolean;
  37750. LIGHTMAPDIRECTUV: number;
  37751. OBJECTSPACE_NORMALMAP: boolean;
  37752. USELIGHTMAPASSHADOWMAP: boolean;
  37753. REFLECTIONMAP_3D: boolean;
  37754. REFLECTIONMAP_SPHERICAL: boolean;
  37755. REFLECTIONMAP_PLANAR: boolean;
  37756. REFLECTIONMAP_CUBIC: boolean;
  37757. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  37758. REFLECTIONMAP_PROJECTION: boolean;
  37759. REFLECTIONMAP_SKYBOX: boolean;
  37760. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  37761. REFLECTIONMAP_EXPLICIT: boolean;
  37762. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  37763. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  37764. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  37765. INVERTCUBICMAP: boolean;
  37766. LOGARITHMICDEPTH: boolean;
  37767. REFRACTION: boolean;
  37768. REFRACTIONMAP_3D: boolean;
  37769. REFLECTIONOVERALPHA: boolean;
  37770. TWOSIDEDLIGHTING: boolean;
  37771. SHADOWFLOAT: boolean;
  37772. MORPHTARGETS: boolean;
  37773. MORPHTARGETS_NORMAL: boolean;
  37774. MORPHTARGETS_TANGENT: boolean;
  37775. NUM_MORPH_INFLUENCERS: number;
  37776. NONUNIFORMSCALING: boolean;
  37777. PREMULTIPLYALPHA: boolean;
  37778. IMAGEPROCESSING: boolean;
  37779. VIGNETTE: boolean;
  37780. VIGNETTEBLENDMODEMULTIPLY: boolean;
  37781. VIGNETTEBLENDMODEOPAQUE: boolean;
  37782. TONEMAPPING: boolean;
  37783. TONEMAPPING_ACES: boolean;
  37784. CONTRAST: boolean;
  37785. COLORCURVES: boolean;
  37786. COLORGRADING: boolean;
  37787. COLORGRADING3D: boolean;
  37788. SAMPLER3DGREENDEPTH: boolean;
  37789. SAMPLER3DBGRMAP: boolean;
  37790. IMAGEPROCESSINGPOSTPROCESS: boolean;
  37791. MULTIVIEW: boolean;
  37792. /**
  37793. * If the reflection texture on this material is in linear color space
  37794. * @hidden
  37795. */
  37796. IS_REFLECTION_LINEAR: boolean;
  37797. /**
  37798. * If the refraction texture on this material is in linear color space
  37799. * @hidden
  37800. */
  37801. IS_REFRACTION_LINEAR: boolean;
  37802. EXPOSURE: boolean;
  37803. constructor();
  37804. setReflectionMode(modeToEnable: string): void;
  37805. }
  37806. /**
  37807. * This is the default material used in Babylon. It is the best trade off between quality
  37808. * and performances.
  37809. * @see http://doc.babylonjs.com/babylon101/materials
  37810. */
  37811. export class StandardMaterial extends PushMaterial {
  37812. private _diffuseTexture;
  37813. /**
  37814. * The basic texture of the material as viewed under a light.
  37815. */
  37816. diffuseTexture: Nullable<BaseTexture>;
  37817. private _ambientTexture;
  37818. /**
  37819. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  37820. */
  37821. ambientTexture: Nullable<BaseTexture>;
  37822. private _opacityTexture;
  37823. /**
  37824. * Define the transparency of the material from a texture.
  37825. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  37826. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  37827. */
  37828. opacityTexture: Nullable<BaseTexture>;
  37829. private _reflectionTexture;
  37830. /**
  37831. * Define the texture used to display the reflection.
  37832. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37833. */
  37834. reflectionTexture: Nullable<BaseTexture>;
  37835. private _emissiveTexture;
  37836. /**
  37837. * Define texture of the material as if self lit.
  37838. * This will be mixed in the final result even in the absence of light.
  37839. */
  37840. emissiveTexture: Nullable<BaseTexture>;
  37841. private _specularTexture;
  37842. /**
  37843. * Define how the color and intensity of the highlight given by the light in the material.
  37844. */
  37845. specularTexture: Nullable<BaseTexture>;
  37846. private _bumpTexture;
  37847. /**
  37848. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  37849. * 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.
  37850. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  37851. */
  37852. bumpTexture: Nullable<BaseTexture>;
  37853. private _lightmapTexture;
  37854. /**
  37855. * Complex lighting can be computationally expensive to compute at runtime.
  37856. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  37857. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  37858. */
  37859. lightmapTexture: Nullable<BaseTexture>;
  37860. private _refractionTexture;
  37861. /**
  37862. * Define the texture used to display the refraction.
  37863. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37864. */
  37865. refractionTexture: Nullable<BaseTexture>;
  37866. /**
  37867. * The color of the material lit by the environmental background lighting.
  37868. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  37869. */
  37870. ambientColor: Color3;
  37871. /**
  37872. * The basic color of the material as viewed under a light.
  37873. */
  37874. diffuseColor: Color3;
  37875. /**
  37876. * Define how the color and intensity of the highlight given by the light in the material.
  37877. */
  37878. specularColor: Color3;
  37879. /**
  37880. * Define the color of the material as if self lit.
  37881. * This will be mixed in the final result even in the absence of light.
  37882. */
  37883. emissiveColor: Color3;
  37884. /**
  37885. * Defines how sharp are the highlights in the material.
  37886. * The bigger the value the sharper giving a more glossy feeling to the result.
  37887. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  37888. */
  37889. specularPower: number;
  37890. private _useAlphaFromDiffuseTexture;
  37891. /**
  37892. * Does the transparency come from the diffuse texture alpha channel.
  37893. */
  37894. useAlphaFromDiffuseTexture: boolean;
  37895. private _useEmissiveAsIllumination;
  37896. /**
  37897. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  37898. */
  37899. useEmissiveAsIllumination: boolean;
  37900. private _linkEmissiveWithDiffuse;
  37901. /**
  37902. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  37903. * the emissive level when the final color is close to one.
  37904. */
  37905. linkEmissiveWithDiffuse: boolean;
  37906. private _useSpecularOverAlpha;
  37907. /**
  37908. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  37909. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  37910. */
  37911. useSpecularOverAlpha: boolean;
  37912. private _useReflectionOverAlpha;
  37913. /**
  37914. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  37915. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  37916. */
  37917. useReflectionOverAlpha: boolean;
  37918. private _disableLighting;
  37919. /**
  37920. * Does lights from the scene impacts this material.
  37921. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  37922. */
  37923. disableLighting: boolean;
  37924. private _useObjectSpaceNormalMap;
  37925. /**
  37926. * Allows using an object space normal map (instead of tangent space).
  37927. */
  37928. useObjectSpaceNormalMap: boolean;
  37929. private _useParallax;
  37930. /**
  37931. * Is parallax enabled or not.
  37932. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  37933. */
  37934. useParallax: boolean;
  37935. private _useParallaxOcclusion;
  37936. /**
  37937. * Is parallax occlusion enabled or not.
  37938. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  37939. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  37940. */
  37941. useParallaxOcclusion: boolean;
  37942. /**
  37943. * 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.
  37944. */
  37945. parallaxScaleBias: number;
  37946. private _roughness;
  37947. /**
  37948. * Helps to define how blurry the reflections should appears in the material.
  37949. */
  37950. roughness: number;
  37951. /**
  37952. * In case of refraction, define the value of the indice of refraction.
  37953. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37954. */
  37955. indexOfRefraction: number;
  37956. /**
  37957. * Invert the refraction texture alongside the y axis.
  37958. * It can be useful with procedural textures or probe for instance.
  37959. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37960. */
  37961. invertRefractionY: boolean;
  37962. /**
  37963. * Defines the alpha limits in alpha test mode.
  37964. */
  37965. alphaCutOff: number;
  37966. private _useLightmapAsShadowmap;
  37967. /**
  37968. * In case of light mapping, define whether the map contains light or shadow informations.
  37969. */
  37970. useLightmapAsShadowmap: boolean;
  37971. private _diffuseFresnelParameters;
  37972. /**
  37973. * Define the diffuse fresnel parameters of the material.
  37974. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37975. */
  37976. diffuseFresnelParameters: FresnelParameters;
  37977. private _opacityFresnelParameters;
  37978. /**
  37979. * Define the opacity fresnel parameters of the material.
  37980. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37981. */
  37982. opacityFresnelParameters: FresnelParameters;
  37983. private _reflectionFresnelParameters;
  37984. /**
  37985. * Define the reflection fresnel parameters of the material.
  37986. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37987. */
  37988. reflectionFresnelParameters: FresnelParameters;
  37989. private _refractionFresnelParameters;
  37990. /**
  37991. * Define the refraction fresnel parameters of the material.
  37992. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37993. */
  37994. refractionFresnelParameters: FresnelParameters;
  37995. private _emissiveFresnelParameters;
  37996. /**
  37997. * Define the emissive fresnel parameters of the material.
  37998. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37999. */
  38000. emissiveFresnelParameters: FresnelParameters;
  38001. private _useReflectionFresnelFromSpecular;
  38002. /**
  38003. * If true automatically deducts the fresnels values from the material specularity.
  38004. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38005. */
  38006. useReflectionFresnelFromSpecular: boolean;
  38007. private _useGlossinessFromSpecularMapAlpha;
  38008. /**
  38009. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  38010. */
  38011. useGlossinessFromSpecularMapAlpha: boolean;
  38012. private _maxSimultaneousLights;
  38013. /**
  38014. * Defines the maximum number of lights that can be used in the material
  38015. */
  38016. maxSimultaneousLights: number;
  38017. private _invertNormalMapX;
  38018. /**
  38019. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  38020. */
  38021. invertNormalMapX: boolean;
  38022. private _invertNormalMapY;
  38023. /**
  38024. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  38025. */
  38026. invertNormalMapY: boolean;
  38027. private _twoSidedLighting;
  38028. /**
  38029. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38030. */
  38031. twoSidedLighting: boolean;
  38032. /**
  38033. * Default configuration related to image processing available in the standard Material.
  38034. */
  38035. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38036. /**
  38037. * Gets the image processing configuration used either in this material.
  38038. */
  38039. /**
  38040. * Sets the Default image processing configuration used either in the this material.
  38041. *
  38042. * If sets to null, the scene one is in use.
  38043. */
  38044. imageProcessingConfiguration: ImageProcessingConfiguration;
  38045. /**
  38046. * Keep track of the image processing observer to allow dispose and replace.
  38047. */
  38048. private _imageProcessingObserver;
  38049. /**
  38050. * Attaches a new image processing configuration to the Standard Material.
  38051. * @param configuration
  38052. */
  38053. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38054. /**
  38055. * Gets wether the color curves effect is enabled.
  38056. */
  38057. /**
  38058. * Sets wether the color curves effect is enabled.
  38059. */
  38060. cameraColorCurvesEnabled: boolean;
  38061. /**
  38062. * Gets wether the color grading effect is enabled.
  38063. */
  38064. /**
  38065. * Gets wether the color grading effect is enabled.
  38066. */
  38067. cameraColorGradingEnabled: boolean;
  38068. /**
  38069. * Gets wether tonemapping is enabled or not.
  38070. */
  38071. /**
  38072. * Sets wether tonemapping is enabled or not
  38073. */
  38074. cameraToneMappingEnabled: boolean;
  38075. /**
  38076. * The camera exposure used on this material.
  38077. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38078. * This corresponds to a photographic exposure.
  38079. */
  38080. /**
  38081. * The camera exposure used on this material.
  38082. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38083. * This corresponds to a photographic exposure.
  38084. */
  38085. cameraExposure: number;
  38086. /**
  38087. * Gets The camera contrast used on this material.
  38088. */
  38089. /**
  38090. * Sets The camera contrast used on this material.
  38091. */
  38092. cameraContrast: number;
  38093. /**
  38094. * Gets the Color Grading 2D Lookup Texture.
  38095. */
  38096. /**
  38097. * Sets the Color Grading 2D Lookup Texture.
  38098. */
  38099. cameraColorGradingTexture: Nullable<BaseTexture>;
  38100. /**
  38101. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38102. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38103. * 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;
  38104. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38105. */
  38106. /**
  38107. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38108. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38109. * 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;
  38110. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38111. */
  38112. cameraColorCurves: Nullable<ColorCurves>;
  38113. /**
  38114. * Custom callback helping to override the default shader used in the material.
  38115. */
  38116. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  38117. protected _renderTargets: SmartArray<RenderTargetTexture>;
  38118. protected _worldViewProjectionMatrix: Matrix;
  38119. protected _globalAmbientColor: Color3;
  38120. protected _useLogarithmicDepth: boolean;
  38121. /**
  38122. * Instantiates a new standard material.
  38123. * This is the default material used in Babylon. It is the best trade off between quality
  38124. * and performances.
  38125. * @see http://doc.babylonjs.com/babylon101/materials
  38126. * @param name Define the name of the material in the scene
  38127. * @param scene Define the scene the material belong to
  38128. */
  38129. constructor(name: string, scene: Scene);
  38130. /**
  38131. * Gets a boolean indicating that current material needs to register RTT
  38132. */
  38133. readonly hasRenderTargetTextures: boolean;
  38134. /**
  38135. * Gets the current class name of the material e.g. "StandardMaterial"
  38136. * Mainly use in serialization.
  38137. * @returns the class name
  38138. */
  38139. getClassName(): string;
  38140. /**
  38141. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  38142. * You can try switching to logarithmic depth.
  38143. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  38144. */
  38145. useLogarithmicDepth: boolean;
  38146. /**
  38147. * Specifies if the material will require alpha blending
  38148. * @returns a boolean specifying if alpha blending is needed
  38149. */
  38150. needAlphaBlending(): boolean;
  38151. /**
  38152. * Specifies if this material should be rendered in alpha test mode
  38153. * @returns a boolean specifying if an alpha test is needed.
  38154. */
  38155. needAlphaTesting(): boolean;
  38156. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  38157. /**
  38158. * Get the texture used for alpha test purpose.
  38159. * @returns the diffuse texture in case of the standard material.
  38160. */
  38161. getAlphaTestTexture(): Nullable<BaseTexture>;
  38162. /**
  38163. * Get if the submesh is ready to be used and all its information available.
  38164. * Child classes can use it to update shaders
  38165. * @param mesh defines the mesh to check
  38166. * @param subMesh defines which submesh to check
  38167. * @param useInstances specifies that instances should be used
  38168. * @returns a boolean indicating that the submesh is ready or not
  38169. */
  38170. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  38171. /**
  38172. * Builds the material UBO layouts.
  38173. * Used internally during the effect preparation.
  38174. */
  38175. buildUniformLayout(): void;
  38176. /**
  38177. * Unbinds the material from the mesh
  38178. */
  38179. unbind(): void;
  38180. /**
  38181. * Binds the submesh to this material by preparing the effect and shader to draw
  38182. * @param world defines the world transformation matrix
  38183. * @param mesh defines the mesh containing the submesh
  38184. * @param subMesh defines the submesh to bind the material to
  38185. */
  38186. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  38187. /**
  38188. * Get the list of animatables in the material.
  38189. * @returns the list of animatables object used in the material
  38190. */
  38191. getAnimatables(): IAnimatable[];
  38192. /**
  38193. * Gets the active textures from the material
  38194. * @returns an array of textures
  38195. */
  38196. getActiveTextures(): BaseTexture[];
  38197. /**
  38198. * Specifies if the material uses a texture
  38199. * @param texture defines the texture to check against the material
  38200. * @returns a boolean specifying if the material uses the texture
  38201. */
  38202. hasTexture(texture: BaseTexture): boolean;
  38203. /**
  38204. * Disposes the material
  38205. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  38206. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  38207. */
  38208. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  38209. /**
  38210. * Makes a duplicate of the material, and gives it a new name
  38211. * @param name defines the new name for the duplicated material
  38212. * @returns the cloned material
  38213. */
  38214. clone(name: string): StandardMaterial;
  38215. /**
  38216. * Serializes this material in a JSON representation
  38217. * @returns the serialized material object
  38218. */
  38219. serialize(): any;
  38220. /**
  38221. * Creates a standard material from parsed material data
  38222. * @param source defines the JSON representation of the material
  38223. * @param scene defines the hosting scene
  38224. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  38225. * @returns a new standard material
  38226. */
  38227. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  38228. /**
  38229. * Are diffuse textures enabled in the application.
  38230. */
  38231. static DiffuseTextureEnabled: boolean;
  38232. /**
  38233. * Are ambient textures enabled in the application.
  38234. */
  38235. static AmbientTextureEnabled: boolean;
  38236. /**
  38237. * Are opacity textures enabled in the application.
  38238. */
  38239. static OpacityTextureEnabled: boolean;
  38240. /**
  38241. * Are reflection textures enabled in the application.
  38242. */
  38243. static ReflectionTextureEnabled: boolean;
  38244. /**
  38245. * Are emissive textures enabled in the application.
  38246. */
  38247. static EmissiveTextureEnabled: boolean;
  38248. /**
  38249. * Are specular textures enabled in the application.
  38250. */
  38251. static SpecularTextureEnabled: boolean;
  38252. /**
  38253. * Are bump textures enabled in the application.
  38254. */
  38255. static BumpTextureEnabled: boolean;
  38256. /**
  38257. * Are lightmap textures enabled in the application.
  38258. */
  38259. static LightmapTextureEnabled: boolean;
  38260. /**
  38261. * Are refraction textures enabled in the application.
  38262. */
  38263. static RefractionTextureEnabled: boolean;
  38264. /**
  38265. * Are color grading textures enabled in the application.
  38266. */
  38267. static ColorGradingTextureEnabled: boolean;
  38268. /**
  38269. * Are fresnels enabled in the application.
  38270. */
  38271. static FresnelEnabled: boolean;
  38272. }
  38273. }
  38274. declare module BABYLON {
  38275. /**
  38276. * A class extending Texture allowing drawing on a texture
  38277. * @see http://doc.babylonjs.com/how_to/dynamictexture
  38278. */
  38279. export class DynamicTexture extends Texture {
  38280. private _generateMipMaps;
  38281. private _canvas;
  38282. private _context;
  38283. private _engine;
  38284. /**
  38285. * Creates a DynamicTexture
  38286. * @param name defines the name of the texture
  38287. * @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
  38288. * @param scene defines the scene where you want the texture
  38289. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  38290. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  38291. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  38292. */
  38293. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  38294. /**
  38295. * Get the current class name of the texture useful for serialization or dynamic coding.
  38296. * @returns "DynamicTexture"
  38297. */
  38298. getClassName(): string;
  38299. /**
  38300. * Gets the current state of canRescale
  38301. */
  38302. readonly canRescale: boolean;
  38303. private _recreate;
  38304. /**
  38305. * Scales the texture
  38306. * @param ratio the scale factor to apply to both width and height
  38307. */
  38308. scale(ratio: number): void;
  38309. /**
  38310. * Resizes the texture
  38311. * @param width the new width
  38312. * @param height the new height
  38313. */
  38314. scaleTo(width: number, height: number): void;
  38315. /**
  38316. * Gets the context of the canvas used by the texture
  38317. * @returns the canvas context of the dynamic texture
  38318. */
  38319. getContext(): CanvasRenderingContext2D;
  38320. /**
  38321. * Clears the texture
  38322. */
  38323. clear(): void;
  38324. /**
  38325. * Updates the texture
  38326. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38327. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  38328. */
  38329. update(invertY?: boolean, premulAlpha?: boolean): void;
  38330. /**
  38331. * Draws text onto the texture
  38332. * @param text defines the text to be drawn
  38333. * @param x defines the placement of the text from the left
  38334. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  38335. * @param font defines the font to be used with font-style, font-size, font-name
  38336. * @param color defines the color used for the text
  38337. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  38338. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38339. * @param update defines whether texture is immediately update (default is true)
  38340. */
  38341. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  38342. /**
  38343. * Clones the texture
  38344. * @returns the clone of the texture.
  38345. */
  38346. clone(): DynamicTexture;
  38347. /**
  38348. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  38349. * @returns a serialized dynamic texture object
  38350. */
  38351. serialize(): any;
  38352. /** @hidden */ rebuild(): void;
  38353. }
  38354. }
  38355. declare module BABYLON {
  38356. /** @hidden */
  38357. export var imageProcessingPixelShader: {
  38358. name: string;
  38359. shader: string;
  38360. };
  38361. }
  38362. declare module BABYLON {
  38363. /**
  38364. * ImageProcessingPostProcess
  38365. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  38366. */
  38367. export class ImageProcessingPostProcess extends PostProcess {
  38368. /**
  38369. * Default configuration related to image processing available in the PBR Material.
  38370. */
  38371. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38372. /**
  38373. * Gets the image processing configuration used either in this material.
  38374. */
  38375. /**
  38376. * Sets the Default image processing configuration used either in the this material.
  38377. *
  38378. * If sets to null, the scene one is in use.
  38379. */
  38380. imageProcessingConfiguration: ImageProcessingConfiguration;
  38381. /**
  38382. * Keep track of the image processing observer to allow dispose and replace.
  38383. */
  38384. private _imageProcessingObserver;
  38385. /**
  38386. * Attaches a new image processing configuration to the PBR Material.
  38387. * @param configuration
  38388. */
  38389. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  38390. /**
  38391. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38392. */
  38393. /**
  38394. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38395. */
  38396. colorCurves: Nullable<ColorCurves>;
  38397. /**
  38398. * Gets wether the color curves effect is enabled.
  38399. */
  38400. /**
  38401. * Sets wether the color curves effect is enabled.
  38402. */
  38403. colorCurvesEnabled: boolean;
  38404. /**
  38405. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38406. */
  38407. /**
  38408. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38409. */
  38410. colorGradingTexture: Nullable<BaseTexture>;
  38411. /**
  38412. * Gets wether the color grading effect is enabled.
  38413. */
  38414. /**
  38415. * Gets wether the color grading effect is enabled.
  38416. */
  38417. colorGradingEnabled: boolean;
  38418. /**
  38419. * Gets exposure used in the effect.
  38420. */
  38421. /**
  38422. * Sets exposure used in the effect.
  38423. */
  38424. exposure: number;
  38425. /**
  38426. * Gets wether tonemapping is enabled or not.
  38427. */
  38428. /**
  38429. * Sets wether tonemapping is enabled or not
  38430. */
  38431. toneMappingEnabled: boolean;
  38432. /**
  38433. * Gets the type of tone mapping effect.
  38434. */
  38435. /**
  38436. * Sets the type of tone mapping effect.
  38437. */
  38438. toneMappingType: number;
  38439. /**
  38440. * Gets contrast used in the effect.
  38441. */
  38442. /**
  38443. * Sets contrast used in the effect.
  38444. */
  38445. contrast: number;
  38446. /**
  38447. * Gets Vignette stretch size.
  38448. */
  38449. /**
  38450. * Sets Vignette stretch size.
  38451. */
  38452. vignetteStretch: number;
  38453. /**
  38454. * Gets Vignette centre X Offset.
  38455. */
  38456. /**
  38457. * Sets Vignette centre X Offset.
  38458. */
  38459. vignetteCentreX: number;
  38460. /**
  38461. * Gets Vignette centre Y Offset.
  38462. */
  38463. /**
  38464. * Sets Vignette centre Y Offset.
  38465. */
  38466. vignetteCentreY: number;
  38467. /**
  38468. * Gets Vignette weight or intensity of the vignette effect.
  38469. */
  38470. /**
  38471. * Sets Vignette weight or intensity of the vignette effect.
  38472. */
  38473. vignetteWeight: number;
  38474. /**
  38475. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38476. * if vignetteEnabled is set to true.
  38477. */
  38478. /**
  38479. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38480. * if vignetteEnabled is set to true.
  38481. */
  38482. vignetteColor: Color4;
  38483. /**
  38484. * Gets Camera field of view used by the Vignette effect.
  38485. */
  38486. /**
  38487. * Sets Camera field of view used by the Vignette effect.
  38488. */
  38489. vignetteCameraFov: number;
  38490. /**
  38491. * Gets the vignette blend mode allowing different kind of effect.
  38492. */
  38493. /**
  38494. * Sets the vignette blend mode allowing different kind of effect.
  38495. */
  38496. vignetteBlendMode: number;
  38497. /**
  38498. * Gets wether the vignette effect is enabled.
  38499. */
  38500. /**
  38501. * Sets wether the vignette effect is enabled.
  38502. */
  38503. vignetteEnabled: boolean;
  38504. private _fromLinearSpace;
  38505. /**
  38506. * Gets wether the input of the processing is in Gamma or Linear Space.
  38507. */
  38508. /**
  38509. * Sets wether the input of the processing is in Gamma or Linear Space.
  38510. */
  38511. fromLinearSpace: boolean;
  38512. /**
  38513. * Defines cache preventing GC.
  38514. */
  38515. private _defines;
  38516. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  38517. /**
  38518. * "ImageProcessingPostProcess"
  38519. * @returns "ImageProcessingPostProcess"
  38520. */
  38521. getClassName(): string;
  38522. protected _updateParameters(): void;
  38523. dispose(camera?: Camera): void;
  38524. }
  38525. }
  38526. declare module BABYLON {
  38527. /**
  38528. * Class containing static functions to help procedurally build meshes
  38529. */
  38530. export class GroundBuilder {
  38531. /**
  38532. * Creates a ground mesh
  38533. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  38534. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  38535. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38536. * @param name defines the name of the mesh
  38537. * @param options defines the options used to create the mesh
  38538. * @param scene defines the hosting scene
  38539. * @returns the ground mesh
  38540. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  38541. */
  38542. static CreateGround(name: string, options: {
  38543. width?: number;
  38544. height?: number;
  38545. subdivisions?: number;
  38546. subdivisionsX?: number;
  38547. subdivisionsY?: number;
  38548. updatable?: boolean;
  38549. }, scene: any): Mesh;
  38550. /**
  38551. * Creates a tiled ground mesh
  38552. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  38553. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  38554. * * 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
  38555. * * 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
  38556. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38557. * @param name defines the name of the mesh
  38558. * @param options defines the options used to create the mesh
  38559. * @param scene defines the hosting scene
  38560. * @returns the tiled ground mesh
  38561. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  38562. */
  38563. static CreateTiledGround(name: string, options: {
  38564. xmin: number;
  38565. zmin: number;
  38566. xmax: number;
  38567. zmax: number;
  38568. subdivisions?: {
  38569. w: number;
  38570. h: number;
  38571. };
  38572. precision?: {
  38573. w: number;
  38574. h: number;
  38575. };
  38576. updatable?: boolean;
  38577. }, scene?: Nullable<Scene>): Mesh;
  38578. /**
  38579. * Creates a ground mesh from a height map
  38580. * * The parameter `url` sets the URL of the height map image resource.
  38581. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  38582. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  38583. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  38584. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  38585. * * 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.
  38586. * * 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).
  38587. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  38588. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38589. * @param name defines the name of the mesh
  38590. * @param url defines the url to the height map
  38591. * @param options defines the options used to create the mesh
  38592. * @param scene defines the hosting scene
  38593. * @returns the ground mesh
  38594. * @see https://doc.babylonjs.com/babylon101/height_map
  38595. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  38596. */
  38597. static CreateGroundFromHeightMap(name: string, url: string, options: {
  38598. width?: number;
  38599. height?: number;
  38600. subdivisions?: number;
  38601. minHeight?: number;
  38602. maxHeight?: number;
  38603. colorFilter?: Color3;
  38604. alphaFilter?: number;
  38605. updatable?: boolean;
  38606. onReady?: (mesh: GroundMesh) => void;
  38607. }, scene?: Nullable<Scene>): GroundMesh;
  38608. }
  38609. }
  38610. declare module BABYLON {
  38611. /**
  38612. * Class containing static functions to help procedurally build meshes
  38613. */
  38614. export class TorusBuilder {
  38615. /**
  38616. * Creates a torus mesh
  38617. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  38618. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  38619. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  38620. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38621. * * If you create a double-sided mesh, you can choose what parts of 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
  38622. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38623. * @param name defines the name of the mesh
  38624. * @param options defines the options used to create the mesh
  38625. * @param scene defines the hosting scene
  38626. * @returns the torus mesh
  38627. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  38628. */
  38629. static CreateTorus(name: string, options: {
  38630. diameter?: number;
  38631. thickness?: number;
  38632. tessellation?: number;
  38633. updatable?: boolean;
  38634. sideOrientation?: number;
  38635. frontUVs?: Vector4;
  38636. backUVs?: Vector4;
  38637. }, scene: any): Mesh;
  38638. }
  38639. }
  38640. declare module BABYLON {
  38641. /**
  38642. * Class containing static functions to help procedurally build meshes
  38643. */
  38644. export class CylinderBuilder {
  38645. /**
  38646. * Creates a cylinder or a cone mesh
  38647. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  38648. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  38649. * * 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.
  38650. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  38651. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  38652. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  38653. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  38654. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  38655. * * 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).
  38656. * * 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
  38657. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  38658. * * 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
  38659. * * 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.
  38660. * * If `enclose` is false, a ring surface is one element.
  38661. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  38662. * * 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
  38663. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38664. * * If you create a double-sided mesh, you can choose what parts of 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
  38665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38666. * @param name defines the name of the mesh
  38667. * @param options defines the options used to create the mesh
  38668. * @param scene defines the hosting scene
  38669. * @returns the cylinder mesh
  38670. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  38671. */
  38672. static CreateCylinder(name: string, options: {
  38673. height?: number;
  38674. diameterTop?: number;
  38675. diameterBottom?: number;
  38676. diameter?: number;
  38677. tessellation?: number;
  38678. subdivisions?: number;
  38679. arc?: number;
  38680. faceColors?: Color4[];
  38681. faceUV?: Vector4[];
  38682. updatable?: boolean;
  38683. hasRings?: boolean;
  38684. enclose?: boolean;
  38685. sideOrientation?: number;
  38686. frontUVs?: Vector4;
  38687. backUVs?: Vector4;
  38688. }, scene: any): Mesh;
  38689. }
  38690. }
  38691. declare module BABYLON {
  38692. /**
  38693. * Manager for handling gamepads
  38694. */
  38695. export class GamepadManager {
  38696. private _scene?;
  38697. private _babylonGamepads;
  38698. private _oneGamepadConnected;
  38699. /** @hidden */ isMonitoring: boolean;
  38700. private _gamepadEventSupported;
  38701. private _gamepadSupport;
  38702. /**
  38703. * observable to be triggered when the gamepad controller has been connected
  38704. */
  38705. onGamepadConnectedObservable: Observable<Gamepad>;
  38706. /**
  38707. * observable to be triggered when the gamepad controller has been disconnected
  38708. */
  38709. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38710. private _onGamepadConnectedEvent;
  38711. private _onGamepadDisconnectedEvent;
  38712. /**
  38713. * Initializes the gamepad manager
  38714. * @param _scene BabylonJS scene
  38715. */
  38716. constructor(_scene?: Scene | undefined);
  38717. /**
  38718. * The gamepads in the game pad manager
  38719. */
  38720. readonly gamepads: Gamepad[];
  38721. /**
  38722. * Get the gamepad controllers based on type
  38723. * @param type The type of gamepad controller
  38724. * @returns Nullable gamepad
  38725. */
  38726. getGamepadByType(type?: number): Nullable<Gamepad>;
  38727. /**
  38728. * Disposes the gamepad manager
  38729. */
  38730. dispose(): void;
  38731. private _addNewGamepad;
  38732. private _startMonitoringGamepads;
  38733. private _stopMonitoringGamepads;
  38734. /** @hidden */ checkGamepadsStatus(): void;
  38735. private _updateGamepadObjects;
  38736. }
  38737. }
  38738. declare module BABYLON {
  38739. interface Scene {
  38740. /** @hidden */ gamepadManager: Nullable<GamepadManager>;
  38741. /**
  38742. * Gets the gamepad manager associated with the scene
  38743. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38744. */
  38745. gamepadManager: GamepadManager;
  38746. }
  38747. /**
  38748. * Interface representing a free camera inputs manager
  38749. */
  38750. interface FreeCameraInputsManager {
  38751. /**
  38752. * Adds gamepad input support to the FreeCameraInputsManager.
  38753. * @returns the FreeCameraInputsManager
  38754. */
  38755. addGamepad(): FreeCameraInputsManager;
  38756. }
  38757. /**
  38758. * Interface representing an arc rotate camera inputs manager
  38759. */
  38760. interface ArcRotateCameraInputsManager {
  38761. /**
  38762. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38763. * @returns the camera inputs manager
  38764. */
  38765. addGamepad(): ArcRotateCameraInputsManager;
  38766. }
  38767. /**
  38768. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38769. */
  38770. export class GamepadSystemSceneComponent implements ISceneComponent {
  38771. /**
  38772. * The component name helpfull to identify the component in the list of scene components.
  38773. */
  38774. readonly name: string;
  38775. /**
  38776. * The scene the component belongs to.
  38777. */
  38778. scene: Scene;
  38779. /**
  38780. * Creates a new instance of the component for the given scene
  38781. * @param scene Defines the scene to register the component in
  38782. */
  38783. constructor(scene: Scene);
  38784. /**
  38785. * Registers the component in a given scene
  38786. */
  38787. register(): void;
  38788. /**
  38789. * Rebuilds the elements related to this component in case of
  38790. * context lost for instance.
  38791. */
  38792. rebuild(): void;
  38793. /**
  38794. * Disposes the component and the associated ressources
  38795. */
  38796. dispose(): void;
  38797. private _beforeCameraUpdate;
  38798. }
  38799. }
  38800. declare module BABYLON {
  38801. /**
  38802. * Options to modify the vr teleportation behavior.
  38803. */
  38804. export interface VRTeleportationOptions {
  38805. /**
  38806. * The name of the mesh which should be used as the teleportation floor. (default: null)
  38807. */
  38808. floorMeshName?: string;
  38809. /**
  38810. * A list of meshes to be used as the teleportation floor. (default: empty)
  38811. */
  38812. floorMeshes?: Mesh[];
  38813. }
  38814. /**
  38815. * Options to modify the vr experience helper's behavior.
  38816. */
  38817. export interface VRExperienceHelperOptions extends WebVROptions {
  38818. /**
  38819. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  38820. */
  38821. createDeviceOrientationCamera?: boolean;
  38822. /**
  38823. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  38824. */
  38825. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  38826. /**
  38827. * Uses the main button on the controller to toggle the laser casted. (default: true)
  38828. */
  38829. laserToggle?: boolean;
  38830. /**
  38831. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  38832. */
  38833. floorMeshes?: Mesh[];
  38834. /**
  38835. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  38836. */
  38837. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  38838. }
  38839. /**
  38840. * Event containing information after VR has been entered
  38841. */
  38842. export class OnAfterEnteringVRObservableEvent {
  38843. /**
  38844. * If entering vr was successful
  38845. */
  38846. success: boolean;
  38847. }
  38848. /**
  38849. * Helps to quickly add VR support to an existing scene.
  38850. * See http://doc.babylonjs.com/how_to/webvr_helper
  38851. */
  38852. export class VRExperienceHelper {
  38853. /** Options to modify the vr experience helper's behavior. */
  38854. webVROptions: VRExperienceHelperOptions;
  38855. private _scene;
  38856. private _position;
  38857. private _btnVR;
  38858. private _btnVRDisplayed;
  38859. private _webVRsupported;
  38860. private _webVRready;
  38861. private _webVRrequesting;
  38862. private _webVRpresenting;
  38863. private _hasEnteredVR;
  38864. private _fullscreenVRpresenting;
  38865. private _canvas;
  38866. private _webVRCamera;
  38867. private _vrDeviceOrientationCamera;
  38868. private _deviceOrientationCamera;
  38869. private _existingCamera;
  38870. private _onKeyDown;
  38871. private _onVrDisplayPresentChange;
  38872. private _onVRDisplayChanged;
  38873. private _onVRRequestPresentStart;
  38874. private _onVRRequestPresentComplete;
  38875. /**
  38876. * Observable raised right before entering VR.
  38877. */
  38878. onEnteringVRObservable: Observable<VRExperienceHelper>;
  38879. /**
  38880. * Observable raised when entering VR has completed.
  38881. */
  38882. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  38883. /**
  38884. * Observable raised when exiting VR.
  38885. */
  38886. onExitingVRObservable: Observable<VRExperienceHelper>;
  38887. /**
  38888. * Observable raised when controller mesh is loaded.
  38889. */
  38890. onControllerMeshLoadedObservable: Observable<WebVRController>;
  38891. /** Return this.onEnteringVRObservable
  38892. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  38893. */
  38894. readonly onEnteringVR: Observable<VRExperienceHelper>;
  38895. /** Return this.onExitingVRObservable
  38896. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  38897. */
  38898. readonly onExitingVR: Observable<VRExperienceHelper>;
  38899. /** Return this.onControllerMeshLoadedObservable
  38900. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  38901. */
  38902. readonly onControllerMeshLoaded: Observable<WebVRController>;
  38903. private _rayLength;
  38904. private _useCustomVRButton;
  38905. private _teleportationRequested;
  38906. private _teleportActive;
  38907. private _floorMeshName;
  38908. private _floorMeshesCollection;
  38909. private _rotationAllowed;
  38910. private _teleportBackwardsVector;
  38911. private _teleportationTarget;
  38912. private _isDefaultTeleportationTarget;
  38913. private _postProcessMove;
  38914. private _teleportationFillColor;
  38915. private _teleportationBorderColor;
  38916. private _rotationAngle;
  38917. private _haloCenter;
  38918. private _cameraGazer;
  38919. private _padSensibilityUp;
  38920. private _padSensibilityDown;
  38921. private _leftController;
  38922. private _rightController;
  38923. /**
  38924. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  38925. */
  38926. onNewMeshSelected: Observable<AbstractMesh>;
  38927. /**
  38928. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  38929. */
  38930. onNewMeshPicked: Observable<PickingInfo>;
  38931. private _circleEase;
  38932. /**
  38933. * Observable raised before camera teleportation
  38934. */
  38935. onBeforeCameraTeleport: Observable<Vector3>;
  38936. /**
  38937. * Observable raised after camera teleportation
  38938. */
  38939. onAfterCameraTeleport: Observable<Vector3>;
  38940. /**
  38941. * Observable raised when current selected mesh gets unselected
  38942. */
  38943. onSelectedMeshUnselected: Observable<AbstractMesh>;
  38944. private _raySelectionPredicate;
  38945. /**
  38946. * To be optionaly changed by user to define custom ray selection
  38947. */
  38948. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  38949. /**
  38950. * To be optionaly changed by user to define custom selection logic (after ray selection)
  38951. */
  38952. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  38953. /**
  38954. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  38955. */
  38956. teleportationEnabled: boolean;
  38957. private _defaultHeight;
  38958. private _teleportationInitialized;
  38959. private _interactionsEnabled;
  38960. private _interactionsRequested;
  38961. private _displayGaze;
  38962. private _displayLaserPointer;
  38963. /**
  38964. * The mesh used to display where the user is going to teleport.
  38965. */
  38966. /**
  38967. * Sets the mesh to be used to display where the user is going to teleport.
  38968. */
  38969. teleportationTarget: Mesh;
  38970. /**
  38971. * 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
  38972. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  38973. * See http://doc.babylonjs.com/resources/baking_transformations
  38974. */
  38975. gazeTrackerMesh: Mesh;
  38976. /**
  38977. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  38978. */
  38979. updateGazeTrackerScale: boolean;
  38980. /**
  38981. * If the gaze trackers color should be updated when selecting meshes
  38982. */
  38983. updateGazeTrackerColor: boolean;
  38984. /**
  38985. * The gaze tracking mesh corresponding to the left controller
  38986. */
  38987. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  38988. /**
  38989. * The gaze tracking mesh corresponding to the right controller
  38990. */
  38991. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  38992. /**
  38993. * If the ray of the gaze should be displayed.
  38994. */
  38995. /**
  38996. * Sets if the ray of the gaze should be displayed.
  38997. */
  38998. displayGaze: boolean;
  38999. /**
  39000. * If the ray of the LaserPointer should be displayed.
  39001. */
  39002. /**
  39003. * Sets if the ray of the LaserPointer should be displayed.
  39004. */
  39005. displayLaserPointer: boolean;
  39006. /**
  39007. * The deviceOrientationCamera used as the camera when not in VR.
  39008. */
  39009. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39010. /**
  39011. * Based on the current WebVR support, returns the current VR camera used.
  39012. */
  39013. readonly currentVRCamera: Nullable<Camera>;
  39014. /**
  39015. * The webVRCamera which is used when in VR.
  39016. */
  39017. readonly webVRCamera: WebVRFreeCamera;
  39018. /**
  39019. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39020. */
  39021. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39022. private readonly _teleportationRequestInitiated;
  39023. /**
  39024. * Defines wether or not Pointer lock should be requested when switching to
  39025. * full screen.
  39026. */
  39027. requestPointerLockOnFullScreen: boolean;
  39028. /**
  39029. * Instantiates a VRExperienceHelper.
  39030. * Helps to quickly add VR support to an existing scene.
  39031. * @param scene The scene the VRExperienceHelper belongs to.
  39032. * @param webVROptions Options to modify the vr experience helper's behavior.
  39033. */
  39034. constructor(scene: Scene,
  39035. /** Options to modify the vr experience helper's behavior. */
  39036. webVROptions?: VRExperienceHelperOptions);
  39037. private _onDefaultMeshLoaded;
  39038. private _onResize;
  39039. private _onFullscreenChange;
  39040. /**
  39041. * Gets a value indicating if we are currently in VR mode.
  39042. */
  39043. readonly isInVRMode: boolean;
  39044. private onVrDisplayPresentChange;
  39045. private onVRDisplayChanged;
  39046. private moveButtonToBottomRight;
  39047. private displayVRButton;
  39048. private updateButtonVisibility;
  39049. private _cachedAngularSensibility;
  39050. /**
  39051. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39052. * Otherwise, will use the fullscreen API.
  39053. */
  39054. enterVR(): void;
  39055. /**
  39056. * Attempt to exit VR, or fullscreen.
  39057. */
  39058. exitVR(): void;
  39059. /**
  39060. * The position of the vr experience helper.
  39061. */
  39062. /**
  39063. * Sets the position of the vr experience helper.
  39064. */
  39065. position: Vector3;
  39066. /**
  39067. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39068. */
  39069. enableInteractions(): void;
  39070. private readonly _noControllerIsActive;
  39071. private beforeRender;
  39072. private _isTeleportationFloor;
  39073. /**
  39074. * Adds a floor mesh to be used for teleportation.
  39075. * @param floorMesh the mesh to be used for teleportation.
  39076. */
  39077. addFloorMesh(floorMesh: Mesh): void;
  39078. /**
  39079. * Removes a floor mesh from being used for teleportation.
  39080. * @param floorMesh the mesh to be removed.
  39081. */
  39082. removeFloorMesh(floorMesh: Mesh): void;
  39083. /**
  39084. * Enables interactions and teleportation using the VR controllers and gaze.
  39085. * @param vrTeleportationOptions options to modify teleportation behavior.
  39086. */
  39087. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39088. private _onNewGamepadConnected;
  39089. private _tryEnableInteractionOnController;
  39090. private _onNewGamepadDisconnected;
  39091. private _enableInteractionOnController;
  39092. private _checkTeleportWithRay;
  39093. private _checkRotate;
  39094. private _checkTeleportBackwards;
  39095. private _enableTeleportationOnController;
  39096. private _createTeleportationCircles;
  39097. private _displayTeleportationTarget;
  39098. private _hideTeleportationTarget;
  39099. private _rotateCamera;
  39100. private _moveTeleportationSelectorTo;
  39101. private _workingVector;
  39102. private _workingQuaternion;
  39103. private _workingMatrix;
  39104. /**
  39105. * Teleports the users feet to the desired location
  39106. * @param location The location where the user's feet should be placed
  39107. */
  39108. teleportCamera(location: Vector3): void;
  39109. private _convertNormalToDirectionOfRay;
  39110. private _castRayAndSelectObject;
  39111. private _notifySelectedMeshUnselected;
  39112. /**
  39113. * Sets the color of the laser ray from the vr controllers.
  39114. * @param color new color for the ray.
  39115. */
  39116. changeLaserColor(color: Color3): void;
  39117. /**
  39118. * Sets the color of the ray from the vr headsets gaze.
  39119. * @param color new color for the ray.
  39120. */
  39121. changeGazeColor(color: Color3): void;
  39122. /**
  39123. * Exits VR and disposes of the vr experience helper
  39124. */
  39125. dispose(): void;
  39126. /**
  39127. * Gets the name of the VRExperienceHelper class
  39128. * @returns "VRExperienceHelper"
  39129. */
  39130. getClassName(): string;
  39131. }
  39132. }
  39133. declare module BABYLON {
  39134. /**
  39135. * Manages an XRSession
  39136. * @see https://doc.babylonjs.com/how_to/webxr
  39137. */
  39138. export class WebXRSessionManager implements IDisposable {
  39139. private scene;
  39140. /**
  39141. * Fires every time a new xrFrame arrives which can be used to update the camera
  39142. */
  39143. onXRFrameObservable: Observable<any>;
  39144. /**
  39145. * Fires when the xr session is ended either by the device or manually done
  39146. */
  39147. onXRSessionEnded: Observable<any>;
  39148. /** @hidden */ xrSession: XRSession;
  39149. /** @hidden */ frameOfReference: XRFrameOfReference;
  39150. /** @hidden */ sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  39151. /** @hidden */ currentXRFrame: Nullable<XRFrame>;
  39152. private _xrNavigator;
  39153. private _xrDevice;
  39154. private _tmpMatrix;
  39155. /**
  39156. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  39157. * @param scene The scene which the session should be created for
  39158. */
  39159. constructor(scene: Scene);
  39160. /**
  39161. * Initializes the manager
  39162. * After initialization enterXR can be called to start an XR session
  39163. * @returns Promise which resolves after it is initialized
  39164. */
  39165. initializeAsync(): Promise<void>;
  39166. /**
  39167. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  39168. * @param sessionCreationOptions xr options to create the session with
  39169. * @param frameOfReferenceType option to configure how the xr pose is expressed
  39170. * @returns Promise which resolves after it enters XR
  39171. */
  39172. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  39173. /**
  39174. * Stops the xrSession and restores the renderloop
  39175. * @returns Promise which resolves after it exits XR
  39176. */
  39177. exitXRAsync(): Promise<void>;
  39178. /**
  39179. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39180. * @param ray ray to cast into the environment
  39181. * @returns Promise which resolves with a collision point in the environment if it exists
  39182. */
  39183. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39184. /**
  39185. * Checks if a session would be supported for the creation options specified
  39186. * @param options creation options to check if they are supported
  39187. * @returns true if supported
  39188. */
  39189. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39190. /**
  39191. * @hidden
  39192. * Converts the render layer of xrSession to a render target
  39193. * @param session session to create render target for
  39194. * @param scene scene the new render target should be created for
  39195. */ private static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  39196. /**
  39197. * Disposes of the session manager
  39198. */
  39199. dispose(): void;
  39200. }
  39201. }
  39202. declare module BABYLON {
  39203. /**
  39204. * WebXR Camera which holds the views for the xrSession
  39205. * @see https://doc.babylonjs.com/how_to/webxr
  39206. */
  39207. export class WebXRCamera extends FreeCamera {
  39208. private static _TmpMatrix;
  39209. /**
  39210. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  39211. * @param name the name of the camera
  39212. * @param scene the scene to add the camera to
  39213. */
  39214. constructor(name: string, scene: Scene);
  39215. private _updateNumberOfRigCameras;
  39216. /** @hidden */ updateForDualEyeDebugging(pupilDistance?: number): void;
  39217. /**
  39218. * Updates the cameras position from the current pose information of the XR session
  39219. * @param xrSessionManager the session containing pose information
  39220. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  39221. */
  39222. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  39223. }
  39224. }
  39225. declare module BABYLON {
  39226. /**
  39227. * States of the webXR experience
  39228. */
  39229. export enum WebXRState {
  39230. /**
  39231. * Transitioning to being in XR mode
  39232. */
  39233. ENTERING_XR = 0,
  39234. /**
  39235. * Transitioning to non XR mode
  39236. */
  39237. EXITING_XR = 1,
  39238. /**
  39239. * In XR mode and presenting
  39240. */
  39241. IN_XR = 2,
  39242. /**
  39243. * Not entered XR mode
  39244. */
  39245. NOT_IN_XR = 3
  39246. }
  39247. /**
  39248. * Helper class used to enable XR
  39249. * @see https://doc.babylonjs.com/how_to/webxr
  39250. */
  39251. export class WebXRExperienceHelper implements IDisposable {
  39252. private scene;
  39253. /**
  39254. * 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
  39255. */
  39256. container: AbstractMesh;
  39257. /**
  39258. * Camera used to render xr content
  39259. */
  39260. camera: WebXRCamera;
  39261. /**
  39262. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  39263. */
  39264. state: WebXRState;
  39265. private _setState;
  39266. private static _TmpVector;
  39267. /**
  39268. * Fires when the state of the experience helper has changed
  39269. */
  39270. onStateChangedObservable: Observable<WebXRState>;
  39271. /** @hidden */ sessionManager: WebXRSessionManager;
  39272. private _nonVRCamera;
  39273. private _originalSceneAutoClear;
  39274. private _supported;
  39275. /**
  39276. * Creates the experience helper
  39277. * @param scene the scene to attach the experience helper to
  39278. * @returns a promise for the experience helper
  39279. */
  39280. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  39281. /**
  39282. * Creates a WebXRExperienceHelper
  39283. * @param scene The scene the helper should be created in
  39284. */
  39285. private constructor();
  39286. /**
  39287. * Exits XR mode and returns the scene to its original state
  39288. * @returns promise that resolves after xr mode has exited
  39289. */
  39290. exitXRAsync(): Promise<void>;
  39291. /**
  39292. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  39293. * @param sessionCreationOptions options for the XR session
  39294. * @param frameOfReference frame of reference of the XR session
  39295. * @returns promise that resolves after xr mode has entered
  39296. */
  39297. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  39298. /**
  39299. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39300. * @param ray ray to cast into the environment
  39301. * @returns Promise which resolves with a collision point in the environment if it exists
  39302. */
  39303. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39304. /**
  39305. * Updates the global position of the camera by moving the camera's container
  39306. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  39307. * @param position The desired global position of the camera
  39308. */
  39309. setPositionOfCameraUsingContainer(position: Vector3): void;
  39310. /**
  39311. * Rotates the xr camera by rotating the camera's container around the camera's position
  39312. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  39313. * @param rotation the desired quaternion rotation to apply to the camera
  39314. */
  39315. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  39316. /**
  39317. * Checks if the creation options are supported by the xr session
  39318. * @param options creation options
  39319. * @returns true if supported
  39320. */
  39321. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39322. /**
  39323. * Disposes of the experience helper
  39324. */
  39325. dispose(): void;
  39326. }
  39327. }
  39328. declare module BABYLON {
  39329. /**
  39330. * Button which can be used to enter a different mode of XR
  39331. */
  39332. export class WebXREnterExitUIButton {
  39333. /** button element */
  39334. element: HTMLElement;
  39335. /** XR initialization options for the button */
  39336. initializationOptions: XRSessionCreationOptions;
  39337. /**
  39338. * Creates a WebXREnterExitUIButton
  39339. * @param element button element
  39340. * @param initializationOptions XR initialization options for the button
  39341. */
  39342. constructor(
  39343. /** button element */
  39344. element: HTMLElement,
  39345. /** XR initialization options for the button */
  39346. initializationOptions: XRSessionCreationOptions);
  39347. /**
  39348. * Overwritable function which can be used to update the button's visuals when the state changes
  39349. * @param activeButton the current active button in the UI
  39350. */
  39351. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  39352. }
  39353. /**
  39354. * Options to create the webXR UI
  39355. */
  39356. export class WebXREnterExitUIOptions {
  39357. /**
  39358. * Context to enter xr with
  39359. */
  39360. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  39361. /**
  39362. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  39363. */
  39364. customButtons?: Array<WebXREnterExitUIButton>;
  39365. }
  39366. /**
  39367. * UI to allow the user to enter/exit XR mode
  39368. */
  39369. export class WebXREnterExitUI implements IDisposable {
  39370. private scene;
  39371. private _overlay;
  39372. private _buttons;
  39373. private _activeButton;
  39374. /**
  39375. * Fired every time the active button is changed.
  39376. *
  39377. * When xr is entered via a button that launches xr that button will be the callback parameter
  39378. *
  39379. * When exiting xr the callback parameter will be null)
  39380. */
  39381. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  39382. /**
  39383. * Creates UI to allow the user to enter/exit XR mode
  39384. * @param scene the scene to add the ui to
  39385. * @param helper the xr experience helper to enter/exit xr with
  39386. * @param options options to configure the UI
  39387. * @returns the created ui
  39388. */
  39389. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  39390. private constructor();
  39391. private _updateButtons;
  39392. /**
  39393. * Disposes of the object
  39394. */
  39395. dispose(): void;
  39396. }
  39397. }
  39398. declare module BABYLON {
  39399. /**
  39400. * Represents an XR input
  39401. */
  39402. export class WebXRController {
  39403. /**
  39404. * 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
  39405. */
  39406. grip?: AbstractMesh;
  39407. /**
  39408. * Pointer which can be used to select objects or attach a visible laser to
  39409. */
  39410. pointer: AbstractMesh;
  39411. /**
  39412. * Creates the controller
  39413. * @see https://doc.babylonjs.com/how_to/webxr
  39414. * @param scene the scene which the controller should be associated to
  39415. */
  39416. constructor(scene: Scene);
  39417. /**
  39418. * Disposes of the object
  39419. */
  39420. dispose(): void;
  39421. }
  39422. /**
  39423. * XR input used to track XR inputs such as controllers/rays
  39424. */
  39425. export class WebXRInput implements IDisposable {
  39426. private helper;
  39427. /**
  39428. * XR controllers being tracked
  39429. */
  39430. controllers: Array<WebXRController>;
  39431. private _tmpMatrix;
  39432. private _frameObserver;
  39433. /**
  39434. * Initializes the WebXRInput
  39435. * @param helper experience helper which the input should be created for
  39436. */
  39437. constructor(helper: WebXRExperienceHelper);
  39438. /**
  39439. * Disposes of the object
  39440. */
  39441. dispose(): void;
  39442. }
  39443. }
  39444. declare module BABYLON {
  39445. /**
  39446. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  39447. */
  39448. export class WebXRManagedOutputCanvas implements IDisposable {
  39449. private _canvas;
  39450. /**
  39451. * xrpresent context of the canvas which can be used to display/mirror xr content
  39452. */
  39453. canvasContext: Nullable<WebGLRenderingContext>;
  39454. /**
  39455. * Initializes the canvas to be added/removed upon entering/exiting xr
  39456. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  39457. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  39458. */
  39459. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  39460. /**
  39461. * Disposes of the object
  39462. */
  39463. dispose(): void;
  39464. private _setManagedOutputCanvas;
  39465. private _addCanvas;
  39466. private _removeCanvas;
  39467. }
  39468. }
  39469. declare module BABYLON {
  39470. /**
  39471. * Contains an array of blocks representing the octree
  39472. */
  39473. export interface IOctreeContainer<T> {
  39474. /**
  39475. * Blocks within the octree
  39476. */
  39477. blocks: Array<OctreeBlock<T>>;
  39478. }
  39479. /**
  39480. * Class used to store a cell in an octree
  39481. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39482. */
  39483. export class OctreeBlock<T> {
  39484. /**
  39485. * Gets the content of the current block
  39486. */
  39487. entries: T[];
  39488. /**
  39489. * Gets the list of block children
  39490. */
  39491. blocks: Array<OctreeBlock<T>>;
  39492. private _depth;
  39493. private _maxDepth;
  39494. private _capacity;
  39495. private _minPoint;
  39496. private _maxPoint;
  39497. private _boundingVectors;
  39498. private _creationFunc;
  39499. /**
  39500. * Creates a new block
  39501. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  39502. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  39503. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39504. * @param depth defines the current depth of this block in the octree
  39505. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  39506. * @param creationFunc defines a callback to call when an element is added to the block
  39507. */
  39508. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  39509. /**
  39510. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39511. */
  39512. readonly capacity: number;
  39513. /**
  39514. * Gets the minimum vector (in world space) of the block's bounding box
  39515. */
  39516. readonly minPoint: Vector3;
  39517. /**
  39518. * Gets the maximum vector (in world space) of the block's bounding box
  39519. */
  39520. readonly maxPoint: Vector3;
  39521. /**
  39522. * Add a new element to this block
  39523. * @param entry defines the element to add
  39524. */
  39525. addEntry(entry: T): void;
  39526. /**
  39527. * Remove an element from this block
  39528. * @param entry defines the element to remove
  39529. */
  39530. removeEntry(entry: T): void;
  39531. /**
  39532. * Add an array of elements to this block
  39533. * @param entries defines the array of elements to add
  39534. */
  39535. addEntries(entries: T[]): void;
  39536. /**
  39537. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  39538. * @param frustumPlanes defines the frustum planes to test
  39539. * @param selection defines the array to store current content if selection is positive
  39540. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39541. */
  39542. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39543. /**
  39544. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  39545. * @param sphereCenter defines the bounding sphere center
  39546. * @param sphereRadius defines the bounding sphere radius
  39547. * @param selection defines the array to store current content if selection is positive
  39548. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39549. */
  39550. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39551. /**
  39552. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  39553. * @param ray defines the ray to test with
  39554. * @param selection defines the array to store current content if selection is positive
  39555. */
  39556. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  39557. /**
  39558. * Subdivide the content into child blocks (this block will then be empty)
  39559. */
  39560. createInnerBlocks(): void;
  39561. /**
  39562. * @hidden
  39563. */ 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;
  39564. }
  39565. }
  39566. declare module BABYLON {
  39567. /**
  39568. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  39569. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39570. */
  39571. export class Octree<T> {
  39572. /** 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.) */
  39573. maxDepth: number;
  39574. /**
  39575. * Blocks within the octree containing objects
  39576. */
  39577. blocks: Array<OctreeBlock<T>>;
  39578. /**
  39579. * Content stored in the octree
  39580. */
  39581. dynamicContent: T[];
  39582. private _maxBlockCapacity;
  39583. private _selectionContent;
  39584. private _creationFunc;
  39585. /**
  39586. * Creates a octree
  39587. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39588. * @param creationFunc function to be used to instatiate the octree
  39589. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  39590. * @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.)
  39591. */
  39592. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  39593. /** 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.) */
  39594. maxDepth?: number);
  39595. /**
  39596. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  39597. * @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);
  39598. * @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);
  39599. * @param entries meshes to be added to the octree blocks
  39600. */
  39601. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  39602. /**
  39603. * Adds a mesh to the octree
  39604. * @param entry Mesh to add to the octree
  39605. */
  39606. addMesh(entry: T): void;
  39607. /**
  39608. * Remove an element from the octree
  39609. * @param entry defines the element to remove
  39610. */
  39611. removeMesh(entry: T): void;
  39612. /**
  39613. * Selects an array of meshes within the frustum
  39614. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  39615. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  39616. * @returns array of meshes within the frustum
  39617. */
  39618. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  39619. /**
  39620. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  39621. * @param sphereCenter defines the bounding sphere center
  39622. * @param sphereRadius defines the bounding sphere radius
  39623. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39624. * @returns an array of objects that intersect the sphere
  39625. */
  39626. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  39627. /**
  39628. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  39629. * @param ray defines the ray to test with
  39630. * @returns array of intersected objects
  39631. */
  39632. intersectsRay(ray: Ray): SmartArray<T>;
  39633. /**
  39634. * Adds a mesh into the octree block if it intersects the block
  39635. */
  39636. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  39637. /**
  39638. * Adds a submesh into the octree block if it intersects the block
  39639. */
  39640. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  39641. }
  39642. }
  39643. declare module BABYLON {
  39644. interface Scene {
  39645. /**
  39646. * @hidden
  39647. * Backing Filed
  39648. */ selectionOctree: Octree<AbstractMesh>;
  39649. /**
  39650. * Gets the octree used to boost mesh selection (picking)
  39651. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39652. */
  39653. selectionOctree: Octree<AbstractMesh>;
  39654. /**
  39655. * Creates or updates the octree used to boost selection (picking)
  39656. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39657. * @param maxCapacity defines the maximum capacity per leaf
  39658. * @param maxDepth defines the maximum depth of the octree
  39659. * @returns an octree of AbstractMesh
  39660. */
  39661. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  39662. }
  39663. interface AbstractMesh {
  39664. /**
  39665. * @hidden
  39666. * Backing Field
  39667. */ submeshesOctree: Octree<SubMesh>;
  39668. /**
  39669. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  39670. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  39671. * @param maxCapacity defines the maximum size of each block (64 by default)
  39672. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  39673. * @returns the new octree
  39674. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  39675. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39676. */
  39677. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  39678. }
  39679. /**
  39680. * Defines the octree scene component responsible to manage any octrees
  39681. * in a given scene.
  39682. */
  39683. export class OctreeSceneComponent {
  39684. /**
  39685. * The component name helpfull to identify the component in the list of scene components.
  39686. */
  39687. readonly name: string;
  39688. /**
  39689. * The scene the component belongs to.
  39690. */
  39691. scene: Scene;
  39692. /**
  39693. * Indicates if the meshes have been checked to make sure they are isEnabled()
  39694. */
  39695. readonly checksIsEnabled: boolean;
  39696. /**
  39697. * Creates a new instance of the component for the given scene
  39698. * @param scene Defines the scene to register the component in
  39699. */
  39700. constructor(scene: Scene);
  39701. /**
  39702. * Registers the component in a given scene
  39703. */
  39704. register(): void;
  39705. /**
  39706. * Return the list of active meshes
  39707. * @returns the list of active meshes
  39708. */
  39709. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39710. /**
  39711. * Return the list of active sub meshes
  39712. * @param mesh The mesh to get the candidates sub meshes from
  39713. * @returns the list of active sub meshes
  39714. */
  39715. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39716. private _tempRay;
  39717. /**
  39718. * Return the list of sub meshes intersecting with a given local ray
  39719. * @param mesh defines the mesh to find the submesh for
  39720. * @param localRay defines the ray in local space
  39721. * @returns the list of intersecting sub meshes
  39722. */
  39723. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  39724. /**
  39725. * Return the list of sub meshes colliding with a collider
  39726. * @param mesh defines the mesh to find the submesh for
  39727. * @param collider defines the collider to evaluate the collision against
  39728. * @returns the list of colliding sub meshes
  39729. */
  39730. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  39731. /**
  39732. * Rebuilds the elements related to this component in case of
  39733. * context lost for instance.
  39734. */
  39735. rebuild(): void;
  39736. /**
  39737. * Disposes the component and the associated ressources.
  39738. */
  39739. dispose(): void;
  39740. }
  39741. }
  39742. declare module BABYLON {
  39743. /**
  39744. * Renders a layer on top of an existing scene
  39745. */
  39746. export class UtilityLayerRenderer implements IDisposable {
  39747. /** the original scene that will be rendered on top of */
  39748. originalScene: Scene;
  39749. private _pointerCaptures;
  39750. private _lastPointerEvents;
  39751. private static _DefaultUtilityLayer;
  39752. private static _DefaultKeepDepthUtilityLayer;
  39753. private _sharedGizmoLight;
  39754. /**
  39755. * @hidden
  39756. * Light which used by gizmos to get light shading
  39757. */ getSharedGizmoLight(): HemisphericLight;
  39758. /**
  39759. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  39760. */
  39761. pickUtilitySceneFirst: boolean;
  39762. /**
  39763. * 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)
  39764. */
  39765. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  39766. /**
  39767. * 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)
  39768. */
  39769. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  39770. /**
  39771. * The scene that is rendered on top of the original scene
  39772. */
  39773. utilityLayerScene: Scene;
  39774. /**
  39775. * If the utility layer should automatically be rendered on top of existing scene
  39776. */
  39777. shouldRender: boolean;
  39778. /**
  39779. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  39780. */
  39781. onlyCheckPointerDownEvents: boolean;
  39782. /**
  39783. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  39784. */
  39785. processAllEvents: boolean;
  39786. /**
  39787. * Observable raised when the pointer move from the utility layer scene to the main scene
  39788. */
  39789. onPointerOutObservable: Observable<number>;
  39790. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  39791. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  39792. private _afterRenderObserver;
  39793. private _sceneDisposeObserver;
  39794. private _originalPointerObserver;
  39795. /**
  39796. * Instantiates a UtilityLayerRenderer
  39797. * @param originalScene the original scene that will be rendered on top of
  39798. * @param handleEvents boolean indicating if the utility layer should handle events
  39799. */
  39800. constructor(
  39801. /** the original scene that will be rendered on top of */
  39802. originalScene: Scene, handleEvents?: boolean);
  39803. private _notifyObservers;
  39804. /**
  39805. * Renders the utility layers scene on top of the original scene
  39806. */
  39807. render(): void;
  39808. /**
  39809. * Disposes of the renderer
  39810. */
  39811. dispose(): void;
  39812. private _updateCamera;
  39813. }
  39814. }
  39815. declare module BABYLON {
  39816. /**
  39817. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  39818. */
  39819. export class Gizmo implements IDisposable {
  39820. /** The utility layer the gizmo will be added to */
  39821. gizmoLayer: UtilityLayerRenderer;
  39822. /**
  39823. * The root mesh of the gizmo
  39824. */ rootMesh: Mesh;
  39825. private _attachedMesh;
  39826. /**
  39827. * Ratio for the scale of the gizmo (Default: 1)
  39828. */
  39829. scaleRatio: number;
  39830. private _tmpMatrix;
  39831. /**
  39832. * If a custom mesh has been set (Default: false)
  39833. */
  39834. protected _customMeshSet: boolean;
  39835. /**
  39836. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  39837. * * When set, interactions will be enabled
  39838. */
  39839. attachedMesh: Nullable<AbstractMesh>;
  39840. /**
  39841. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  39842. * @param mesh The mesh to replace the default mesh of the gizmo
  39843. */
  39844. setCustomMesh(mesh: Mesh): void;
  39845. /**
  39846. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  39847. */
  39848. updateGizmoRotationToMatchAttachedMesh: boolean;
  39849. /**
  39850. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  39851. */
  39852. updateGizmoPositionToMatchAttachedMesh: boolean;
  39853. /**
  39854. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  39855. */
  39856. protected _updateScale: boolean;
  39857. protected _interactionsEnabled: boolean;
  39858. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  39859. private _beforeRenderObserver;
  39860. /**
  39861. * Creates a gizmo
  39862. * @param gizmoLayer The utility layer the gizmo will be added to
  39863. */
  39864. constructor(
  39865. /** The utility layer the gizmo will be added to */
  39866. gizmoLayer?: UtilityLayerRenderer);
  39867. private _tempVector;
  39868. /**
  39869. * @hidden
  39870. * Updates the gizmo to match the attached mesh's position/rotation
  39871. */
  39872. protected _update(): void;
  39873. /**
  39874. * Disposes of the gizmo
  39875. */
  39876. dispose(): void;
  39877. }
  39878. }
  39879. declare module BABYLON {
  39880. /**
  39881. * Single axis drag gizmo
  39882. */
  39883. export class AxisDragGizmo extends Gizmo {
  39884. /**
  39885. * Drag behavior responsible for the gizmos dragging interactions
  39886. */
  39887. dragBehavior: PointerDragBehavior;
  39888. private _pointerObserver;
  39889. /**
  39890. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  39891. */
  39892. snapDistance: number;
  39893. /**
  39894. * Event that fires each time the gizmo snaps to a new location.
  39895. * * snapDistance is the the change in distance
  39896. */
  39897. onSnapObservable: Observable<{
  39898. snapDistance: number;
  39899. }>;
  39900. /** @hidden */ private static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  39901. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  39902. /**
  39903. * Creates an AxisDragGizmo
  39904. * @param gizmoLayer The utility layer the gizmo will be added to
  39905. * @param dragAxis The axis which the gizmo will be able to drag on
  39906. * @param color The color of the gizmo
  39907. */
  39908. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  39909. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  39910. /**
  39911. * Disposes of the gizmo
  39912. */
  39913. dispose(): void;
  39914. }
  39915. }
  39916. declare module BABYLON.Debug {
  39917. /**
  39918. * The Axes viewer will show 3 axes in a specific point in space
  39919. */
  39920. export class AxesViewer {
  39921. private _xAxis;
  39922. private _yAxis;
  39923. private _zAxis;
  39924. private _scaleLinesFactor;
  39925. private _instanced;
  39926. /**
  39927. * Gets the hosting scene
  39928. */
  39929. scene: Scene;
  39930. /**
  39931. * Gets or sets a number used to scale line length
  39932. */
  39933. scaleLines: number;
  39934. /** Gets the node hierarchy used to render x-axis */
  39935. readonly xAxis: TransformNode;
  39936. /** Gets the node hierarchy used to render y-axis */
  39937. readonly yAxis: TransformNode;
  39938. /** Gets the node hierarchy used to render z-axis */
  39939. readonly zAxis: TransformNode;
  39940. /**
  39941. * Creates a new AxesViewer
  39942. * @param scene defines the hosting scene
  39943. * @param scaleLines defines a number used to scale line length (1 by default)
  39944. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  39945. * @param xAxis defines the node hierarchy used to render the x-axis
  39946. * @param yAxis defines the node hierarchy used to render the y-axis
  39947. * @param zAxis defines the node hierarchy used to render the z-axis
  39948. */
  39949. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  39950. /**
  39951. * Force the viewer to update
  39952. * @param position defines the position of the viewer
  39953. * @param xaxis defines the x axis of the viewer
  39954. * @param yaxis defines the y axis of the viewer
  39955. * @param zaxis defines the z axis of the viewer
  39956. */
  39957. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  39958. /**
  39959. * Creates an instance of this axes viewer.
  39960. * @returns a new axes viewer with instanced meshes
  39961. */
  39962. createInstance(): AxesViewer;
  39963. /** Releases resources */
  39964. dispose(): void;
  39965. private static _SetRenderingGroupId;
  39966. }
  39967. }
  39968. declare module BABYLON.Debug {
  39969. /**
  39970. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  39971. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  39972. */
  39973. export class BoneAxesViewer extends AxesViewer {
  39974. /**
  39975. * Gets or sets the target mesh where to display the axes viewer
  39976. */
  39977. mesh: Nullable<Mesh>;
  39978. /**
  39979. * Gets or sets the target bone where to display the axes viewer
  39980. */
  39981. bone: Nullable<Bone>;
  39982. /** Gets current position */
  39983. pos: Vector3;
  39984. /** Gets direction of X axis */
  39985. xaxis: Vector3;
  39986. /** Gets direction of Y axis */
  39987. yaxis: Vector3;
  39988. /** Gets direction of Z axis */
  39989. zaxis: Vector3;
  39990. /**
  39991. * Creates a new BoneAxesViewer
  39992. * @param scene defines the hosting scene
  39993. * @param bone defines the target bone
  39994. * @param mesh defines the target mesh
  39995. * @param scaleLines defines a scaling factor for line length (1 by default)
  39996. */
  39997. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  39998. /**
  39999. * Force the viewer to update
  40000. */
  40001. update(): void;
  40002. /** Releases resources */
  40003. dispose(): void;
  40004. }
  40005. }
  40006. declare module BABYLON {
  40007. /**
  40008. * Interface used to define scene explorer extensibility option
  40009. */
  40010. export interface IExplorerExtensibilityOption {
  40011. /**
  40012. * Define the option label
  40013. */
  40014. label: string;
  40015. /**
  40016. * Defines the action to execute on click
  40017. */
  40018. action: (entity: any) => void;
  40019. }
  40020. /**
  40021. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  40022. */
  40023. export interface IExplorerExtensibilityGroup {
  40024. /**
  40025. * Defines a predicate to test if a given type mut be extended
  40026. */
  40027. predicate: (entity: any) => boolean;
  40028. /**
  40029. * Gets the list of options added to a type
  40030. */
  40031. entries: IExplorerExtensibilityOption[];
  40032. }
  40033. /**
  40034. * Interface used to define the options to use to create the Inspector
  40035. */
  40036. export interface IInspectorOptions {
  40037. /**
  40038. * Display in overlay mode (default: false)
  40039. */
  40040. overlay?: boolean;
  40041. /**
  40042. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  40043. */
  40044. globalRoot?: HTMLElement;
  40045. /**
  40046. * Display the Scene explorer
  40047. */
  40048. showExplorer?: boolean;
  40049. /**
  40050. * Display the property inspector
  40051. */
  40052. showInspector?: boolean;
  40053. /**
  40054. * Display in embed mode (both panes on the right)
  40055. */
  40056. embedMode?: boolean;
  40057. /**
  40058. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  40059. */
  40060. handleResize?: boolean;
  40061. /**
  40062. * Allow the panes to popup (default: true)
  40063. */
  40064. enablePopup?: boolean;
  40065. /**
  40066. * Allow the panes to be closed by users (default: true)
  40067. */
  40068. enableClose?: boolean;
  40069. /**
  40070. * Optional list of extensibility entries
  40071. */
  40072. explorerExtensibility?: IExplorerExtensibilityGroup[];
  40073. /**
  40074. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  40075. */
  40076. inspectorURL?: string;
  40077. }
  40078. interface Scene {
  40079. /**
  40080. * @hidden
  40081. * Backing field
  40082. */ debugLayer: DebugLayer;
  40083. /**
  40084. * Gets the debug layer (aka Inspector) associated with the scene
  40085. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40086. */
  40087. debugLayer: DebugLayer;
  40088. }
  40089. /**
  40090. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40091. * what is happening in your scene
  40092. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40093. */
  40094. export class DebugLayer {
  40095. /**
  40096. * Define the url to get the inspector script from.
  40097. * By default it uses the babylonjs CDN.
  40098. * @ignoreNaming
  40099. */
  40100. static InspectorURL: string;
  40101. private _scene;
  40102. private BJSINSPECTOR;
  40103. /**
  40104. * Observable triggered when a property is changed through the inspector.
  40105. */
  40106. onPropertyChangedObservable: Observable<{
  40107. object: any;
  40108. property: string;
  40109. value: any;
  40110. initialValue: any;
  40111. }>;
  40112. /**
  40113. * Instantiates a new debug layer.
  40114. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40115. * what is happening in your scene
  40116. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40117. * @param scene Defines the scene to inspect
  40118. */
  40119. constructor(scene: Scene);
  40120. /** Creates the inspector window. */
  40121. private _createInspector;
  40122. /**
  40123. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  40124. * @param entity defines the entity to select
  40125. * @param lineContainerTitle defines the specific block to highlight
  40126. */
  40127. select(entity: any, lineContainerTitle?: string): void;
  40128. /** Get the inspector from bundle or global */
  40129. private _getGlobalInspector;
  40130. /**
  40131. * Get if the inspector is visible or not.
  40132. * @returns true if visible otherwise, false
  40133. */
  40134. isVisible(): boolean;
  40135. /**
  40136. * Hide the inspector and close its window.
  40137. */
  40138. hide(): void;
  40139. /**
  40140. * Launch the debugLayer.
  40141. * @param config Define the configuration of the inspector
  40142. * @return a promise fulfilled when the debug layer is visible
  40143. */
  40144. show(config?: IInspectorOptions): Promise<DebugLayer>;
  40145. }
  40146. }
  40147. declare module BABYLON {
  40148. /**
  40149. * Class containing static functions to help procedurally build meshes
  40150. */
  40151. export class BoxBuilder {
  40152. /**
  40153. * Creates a box mesh
  40154. * * The parameter `size` sets the size (float) of each box side (default 1)
  40155. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  40156. * * 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)
  40157. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  40158. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40159. * * If you create a double-sided mesh, you can choose what parts of 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
  40160. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40161. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  40162. * @param name defines the name of the mesh
  40163. * @param options defines the options used to create the mesh
  40164. * @param scene defines the hosting scene
  40165. * @returns the box mesh
  40166. */
  40167. static CreateBox(name: string, options: {
  40168. size?: number;
  40169. width?: number;
  40170. height?: number;
  40171. depth?: number;
  40172. faceUV?: Vector4[];
  40173. faceColors?: Color4[];
  40174. sideOrientation?: number;
  40175. frontUVs?: Vector4;
  40176. backUVs?: Vector4;
  40177. updatable?: boolean;
  40178. }, scene?: Nullable<Scene>): Mesh;
  40179. }
  40180. }
  40181. declare module BABYLON {
  40182. /**
  40183. * Class containing static functions to help procedurally build meshes
  40184. */
  40185. export class SphereBuilder {
  40186. /**
  40187. * Creates a sphere mesh
  40188. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  40189. * * 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`)
  40190. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  40191. * * 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
  40192. * * 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)
  40193. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40194. * * If you create a double-sided mesh, you can choose what parts of 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
  40195. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40196. * @param name defines the name of the mesh
  40197. * @param options defines the options used to create the mesh
  40198. * @param scene defines the hosting scene
  40199. * @returns the sphere mesh
  40200. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  40201. */
  40202. static CreateSphere(name: string, options: {
  40203. segments?: number;
  40204. diameter?: number;
  40205. diameterX?: number;
  40206. diameterY?: number;
  40207. diameterZ?: number;
  40208. arc?: number;
  40209. slice?: number;
  40210. sideOrientation?: number;
  40211. frontUVs?: Vector4;
  40212. backUVs?: Vector4;
  40213. updatable?: boolean;
  40214. }, scene: any): Mesh;
  40215. }
  40216. }
  40217. declare module BABYLON.Debug {
  40218. /**
  40219. * Used to show the physics impostor around the specific mesh
  40220. */
  40221. export class PhysicsViewer {
  40222. /** @hidden */
  40223. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  40224. /** @hidden */
  40225. protected _meshes: Array<Nullable<AbstractMesh>>;
  40226. /** @hidden */
  40227. protected _scene: Nullable<Scene>;
  40228. /** @hidden */
  40229. protected _numMeshes: number;
  40230. /** @hidden */
  40231. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  40232. private _renderFunction;
  40233. private _utilityLayer;
  40234. private _debugBoxMesh;
  40235. private _debugSphereMesh;
  40236. private _debugCylinderMesh;
  40237. private _debugMaterial;
  40238. private _debugMeshMeshes;
  40239. /**
  40240. * Creates a new PhysicsViewer
  40241. * @param scene defines the hosting scene
  40242. */
  40243. constructor(scene: Scene);
  40244. /** @hidden */
  40245. protected _updateDebugMeshes(): void;
  40246. /**
  40247. * Renders a specified physic impostor
  40248. * @param impostor defines the impostor to render
  40249. * @param targetMesh defines the mesh represented by the impostor
  40250. * @returns the new debug mesh used to render the impostor
  40251. */
  40252. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  40253. /**
  40254. * Hides a specified physic impostor
  40255. * @param impostor defines the impostor to hide
  40256. */
  40257. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  40258. private _getDebugMaterial;
  40259. private _getDebugBoxMesh;
  40260. private _getDebugSphereMesh;
  40261. private _getDebugCylinderMesh;
  40262. private _getDebugMeshMesh;
  40263. private _getDebugMesh;
  40264. /** Releases all resources */
  40265. dispose(): void;
  40266. }
  40267. }
  40268. declare module BABYLON {
  40269. /**
  40270. * Class containing static functions to help procedurally build meshes
  40271. */
  40272. export class LinesBuilder {
  40273. /**
  40274. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  40275. * * 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
  40276. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  40277. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  40278. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  40279. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  40280. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  40281. * * 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
  40282. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  40283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40284. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  40285. * @param name defines the name of the new line system
  40286. * @param options defines the options used to create the line system
  40287. * @param scene defines the hosting scene
  40288. * @returns a new line system mesh
  40289. */
  40290. static CreateLineSystem(name: string, options: {
  40291. lines: Vector3[][];
  40292. updatable?: boolean;
  40293. instance?: Nullable<LinesMesh>;
  40294. colors?: Nullable<Color4[][]>;
  40295. useVertexAlpha?: boolean;
  40296. }, scene: Nullable<Scene>): LinesMesh;
  40297. /**
  40298. * Creates a line mesh
  40299. * 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
  40300. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40301. * * The parameter `points` is an array successive Vector3
  40302. * * 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
  40303. * * The optional parameter `colors` is an array of successive Color4, one per line point
  40304. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  40305. * * When updating an instance, remember that only point positions can change, not the number of points
  40306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40307. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  40308. * @param name defines the name of the new line system
  40309. * @param options defines the options used to create the line system
  40310. * @param scene defines the hosting scene
  40311. * @returns a new line mesh
  40312. */
  40313. static CreateLines(name: string, options: {
  40314. points: Vector3[];
  40315. updatable?: boolean;
  40316. instance?: Nullable<LinesMesh>;
  40317. colors?: Color4[];
  40318. useVertexAlpha?: boolean;
  40319. }, scene?: Nullable<Scene>): LinesMesh;
  40320. /**
  40321. * Creates a dashed line mesh
  40322. * * 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
  40323. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40324. * * The parameter `points` is an array successive Vector3
  40325. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  40326. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  40327. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  40328. * * 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
  40329. * * When updating an instance, remember that only point positions can change, not the number of points
  40330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40331. * @param name defines the name of the mesh
  40332. * @param options defines the options used to create the mesh
  40333. * @param scene defines the hosting scene
  40334. * @returns the dashed line mesh
  40335. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  40336. */
  40337. static CreateDashedLines(name: string, options: {
  40338. points: Vector3[];
  40339. dashSize?: number;
  40340. gapSize?: number;
  40341. dashNb?: number;
  40342. updatable?: boolean;
  40343. instance?: LinesMesh;
  40344. }, scene?: Nullable<Scene>): LinesMesh;
  40345. }
  40346. }
  40347. declare module BABYLON {
  40348. /**
  40349. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40350. * in order to better appreciate the issue one might have.
  40351. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40352. */
  40353. export class RayHelper {
  40354. /**
  40355. * Defines the ray we are currently tryin to visualize.
  40356. */
  40357. ray: Nullable<Ray>;
  40358. private _renderPoints;
  40359. private _renderLine;
  40360. private _renderFunction;
  40361. private _scene;
  40362. private _updateToMeshFunction;
  40363. private _attachedToMesh;
  40364. private _meshSpaceDirection;
  40365. private _meshSpaceOrigin;
  40366. /**
  40367. * Helper function to create a colored helper in a scene in one line.
  40368. * @param ray Defines the ray we are currently tryin to visualize
  40369. * @param scene Defines the scene the ray is used in
  40370. * @param color Defines the color we want to see the ray in
  40371. * @returns The newly created ray helper.
  40372. */
  40373. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  40374. /**
  40375. * Instantiate a new ray helper.
  40376. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40377. * in order to better appreciate the issue one might have.
  40378. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40379. * @param ray Defines the ray we are currently tryin to visualize
  40380. */
  40381. constructor(ray: Ray);
  40382. /**
  40383. * Shows the ray we are willing to debug.
  40384. * @param scene Defines the scene the ray needs to be rendered in
  40385. * @param color Defines the color the ray needs to be rendered in
  40386. */
  40387. show(scene: Scene, color?: Color3): void;
  40388. /**
  40389. * Hides the ray we are debugging.
  40390. */
  40391. hide(): void;
  40392. private _render;
  40393. /**
  40394. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  40395. * @param mesh Defines the mesh we want the helper attached to
  40396. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  40397. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  40398. * @param length Defines the length of the ray
  40399. */
  40400. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  40401. /**
  40402. * Detach the ray helper from the mesh it has previously been attached to.
  40403. */
  40404. detachFromMesh(): void;
  40405. private _updateToMesh;
  40406. /**
  40407. * Dispose the helper and release its associated resources.
  40408. */
  40409. dispose(): void;
  40410. }
  40411. }
  40412. declare module BABYLON.Debug {
  40413. /**
  40414. * Class used to render a debug view of a given skeleton
  40415. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  40416. */
  40417. export class SkeletonViewer {
  40418. /** defines the skeleton to render */
  40419. skeleton: Skeleton;
  40420. /** defines the mesh attached to the skeleton */
  40421. mesh: AbstractMesh;
  40422. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40423. autoUpdateBonesMatrices: boolean;
  40424. /** defines the rendering group id to use with the viewer */
  40425. renderingGroupId: number;
  40426. /** Gets or sets the color used to render the skeleton */
  40427. color: Color3;
  40428. private _scene;
  40429. private _debugLines;
  40430. private _debugMesh;
  40431. private _isEnabled;
  40432. private _renderFunction;
  40433. private _utilityLayer;
  40434. /**
  40435. * Returns the mesh used to render the bones
  40436. */
  40437. readonly debugMesh: Nullable<LinesMesh>;
  40438. /**
  40439. * Creates a new SkeletonViewer
  40440. * @param skeleton defines the skeleton to render
  40441. * @param mesh defines the mesh attached to the skeleton
  40442. * @param scene defines the hosting scene
  40443. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  40444. * @param renderingGroupId defines the rendering group id to use with the viewer
  40445. */
  40446. constructor(
  40447. /** defines the skeleton to render */
  40448. skeleton: Skeleton,
  40449. /** defines the mesh attached to the skeleton */
  40450. mesh: AbstractMesh, scene: Scene,
  40451. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40452. autoUpdateBonesMatrices?: boolean,
  40453. /** defines the rendering group id to use with the viewer */
  40454. renderingGroupId?: number);
  40455. /** Gets or sets a boolean indicating if the viewer is enabled */
  40456. isEnabled: boolean;
  40457. private _getBonePosition;
  40458. private _getLinesForBonesWithLength;
  40459. private _getLinesForBonesNoLength;
  40460. /** Update the viewer to sync with current skeleton state */
  40461. update(): void;
  40462. /** Release associated resources */
  40463. dispose(): void;
  40464. }
  40465. }
  40466. declare module BABYLON {
  40467. /**
  40468. * Options to create the null engine
  40469. */
  40470. export class NullEngineOptions {
  40471. /**
  40472. * Render width (Default: 512)
  40473. */
  40474. renderWidth: number;
  40475. /**
  40476. * Render height (Default: 256)
  40477. */
  40478. renderHeight: number;
  40479. /**
  40480. * Texture size (Default: 512)
  40481. */
  40482. textureSize: number;
  40483. /**
  40484. * If delta time between frames should be constant
  40485. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40486. */
  40487. deterministicLockstep: boolean;
  40488. /**
  40489. * Maximum about of steps between frames (Default: 4)
  40490. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40491. */
  40492. lockstepMaxSteps: number;
  40493. }
  40494. /**
  40495. * The null engine class provides support for headless version of babylon.js.
  40496. * This can be used in server side scenario or for testing purposes
  40497. */
  40498. export class NullEngine extends Engine {
  40499. private _options;
  40500. /**
  40501. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40502. */
  40503. isDeterministicLockStep(): boolean;
  40504. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  40505. getLockstepMaxSteps(): number;
  40506. /**
  40507. * Sets hardware scaling, used to save performance if needed
  40508. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  40509. */
  40510. getHardwareScalingLevel(): number;
  40511. constructor(options?: NullEngineOptions);
  40512. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  40513. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  40514. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40515. getRenderWidth(useScreen?: boolean): number;
  40516. getRenderHeight(useScreen?: boolean): number;
  40517. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  40518. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  40519. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  40520. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  40521. bindSamplers(effect: Effect): void;
  40522. enableEffect(effect: Effect): void;
  40523. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  40524. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  40525. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  40526. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  40527. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  40528. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  40529. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  40530. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  40531. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  40532. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  40533. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  40534. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  40535. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  40536. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  40537. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  40538. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40539. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40540. setFloat(uniform: WebGLUniformLocation, value: number): void;
  40541. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  40542. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  40543. setBool(uniform: WebGLUniformLocation, bool: number): void;
  40544. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  40545. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  40546. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  40547. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  40548. bindBuffers(vertexBuffers: {
  40549. [key: string]: VertexBuffer;
  40550. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  40551. wipeCaches(bruteForce?: boolean): void;
  40552. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40553. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40554. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40555. /** @hidden */ createTexture(): WebGLTexture;
  40556. /** @hidden */ releaseTexture(texture: InternalTexture): void;
  40557. 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;
  40558. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  40559. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  40560. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  40561. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40562. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  40563. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  40564. areAllEffectsReady(): boolean;
  40565. /**
  40566. * @hidden
  40567. * Get the current error code of the webGL context
  40568. * @returns the error code
  40569. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40570. */
  40571. getError(): number;
  40572. /** @hidden */ getUnpackAlignement(): number;
  40573. /** @hidden */ unpackFlipY(value: boolean): void;
  40574. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  40575. /**
  40576. * Updates a dynamic vertex buffer.
  40577. * @param vertexBuffer the vertex buffer to update
  40578. * @param data the data used to update the vertex buffer
  40579. * @param byteOffset the byte offset of the data (optional)
  40580. * @param byteLength the byte length of the data (optional)
  40581. */
  40582. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void; bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  40583. /** @hidden */ bindTexture(channel: number, texture: InternalTexture): void;
  40584. /** @hidden */ releaseBuffer(buffer: WebGLBuffer): boolean;
  40585. releaseEffects(): void;
  40586. displayLoadingUI(): void;
  40587. hideLoadingUI(): void;
  40588. /** @hidden */ uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40589. /** @hidden */ uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40590. /** @hidden */ uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40591. /** @hidden */ uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  40592. }
  40593. }
  40594. declare module BABYLON {
  40595. /** @hidden */
  40596. export class _OcclusionDataStorage {
  40597. /** @hidden */
  40598. occlusionInternalRetryCounter: number;
  40599. /** @hidden */
  40600. isOcclusionQueryInProgress: boolean;
  40601. /** @hidden */
  40602. isOccluded: boolean;
  40603. /** @hidden */
  40604. occlusionRetryCount: number;
  40605. /** @hidden */
  40606. occlusionType: number;
  40607. /** @hidden */
  40608. occlusionQueryAlgorithmType: number;
  40609. }
  40610. interface Engine {
  40611. /**
  40612. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  40613. * @return the new query
  40614. */
  40615. createQuery(): WebGLQuery;
  40616. /**
  40617. * Delete and release a webGL query
  40618. * @param query defines the query to delete
  40619. * @return the current engine
  40620. */
  40621. deleteQuery(query: WebGLQuery): Engine;
  40622. /**
  40623. * Check if a given query has resolved and got its value
  40624. * @param query defines the query to check
  40625. * @returns true if the query got its value
  40626. */
  40627. isQueryResultAvailable(query: WebGLQuery): boolean;
  40628. /**
  40629. * Gets the value of a given query
  40630. * @param query defines the query to check
  40631. * @returns the value of the query
  40632. */
  40633. getQueryResult(query: WebGLQuery): number;
  40634. /**
  40635. * Initiates an occlusion query
  40636. * @param algorithmType defines the algorithm to use
  40637. * @param query defines the query to use
  40638. * @returns the current engine
  40639. * @see http://doc.babylonjs.com/features/occlusionquery
  40640. */
  40641. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  40642. /**
  40643. * Ends an occlusion query
  40644. * @see http://doc.babylonjs.com/features/occlusionquery
  40645. * @param algorithmType defines the algorithm to use
  40646. * @returns the current engine
  40647. */
  40648. endOcclusionQuery(algorithmType: number): Engine;
  40649. /**
  40650. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  40651. * Please note that only one query can be issued at a time
  40652. * @returns a time token used to track the time span
  40653. */
  40654. startTimeQuery(): Nullable<_TimeToken>;
  40655. /**
  40656. * Ends a time query
  40657. * @param token defines the token used to measure the time span
  40658. * @returns the time spent (in ns)
  40659. */
  40660. endTimeQuery(token: _TimeToken): int;
  40661. /** @hidden */ currentNonTimestampToken: Nullable<_TimeToken>;
  40662. /** @hidden */ createTimeQuery(): WebGLQuery;
  40663. /** @hidden */ deleteTimeQuery(query: WebGLQuery): void;
  40664. /** @hidden */ getGlAlgorithmType(algorithmType: number): number;
  40665. /** @hidden */ getTimeQueryResult(query: WebGLQuery): any;
  40666. /** @hidden */ getTimeQueryAvailability(query: WebGLQuery): any;
  40667. }
  40668. interface AbstractMesh {
  40669. /**
  40670. * Backing filed
  40671. * @hidden
  40672. */ private _occlusionDataStorage: _OcclusionDataStorage;
  40673. /**
  40674. * Access property
  40675. * @hidden
  40676. */ occlusionDataStorage: _OcclusionDataStorage;
  40677. /**
  40678. * 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.
  40679. * The default value is -1 which means don't break the query and wait till the result
  40680. * @see http://doc.babylonjs.com/features/occlusionquery
  40681. */
  40682. occlusionRetryCount: number;
  40683. /**
  40684. * 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:
  40685. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  40686. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  40687. * * 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.
  40688. * @see http://doc.babylonjs.com/features/occlusionquery
  40689. */
  40690. occlusionType: number;
  40691. /**
  40692. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  40693. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  40694. * * 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.
  40695. * @see http://doc.babylonjs.com/features/occlusionquery
  40696. */
  40697. occlusionQueryAlgorithmType: number;
  40698. /**
  40699. * 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
  40700. * @see http://doc.babylonjs.com/features/occlusionquery
  40701. */
  40702. isOccluded: boolean;
  40703. /**
  40704. * Flag to check the progress status of the query
  40705. * @see http://doc.babylonjs.com/features/occlusionquery
  40706. */
  40707. isOcclusionQueryInProgress: boolean;
  40708. }
  40709. }
  40710. declare module BABYLON {
  40711. /** @hidden */
  40712. export var _forceTransformFeedbackToBundle: boolean;
  40713. interface Engine {
  40714. /**
  40715. * Creates a webGL transform feedback object
  40716. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  40717. * @returns the webGL transform feedback object
  40718. */
  40719. createTransformFeedback(): WebGLTransformFeedback;
  40720. /**
  40721. * Delete a webGL transform feedback object
  40722. * @param value defines the webGL transform feedback object to delete
  40723. */
  40724. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  40725. /**
  40726. * Bind a webGL transform feedback object to the webgl context
  40727. * @param value defines the webGL transform feedback object to bind
  40728. */
  40729. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  40730. /**
  40731. * Begins a transform feedback operation
  40732. * @param usePoints defines if points or triangles must be used
  40733. */
  40734. beginTransformFeedback(usePoints: boolean): void;
  40735. /**
  40736. * Ends a transform feedback operation
  40737. */
  40738. endTransformFeedback(): void;
  40739. /**
  40740. * Specify the varyings to use with transform feedback
  40741. * @param program defines the associated webGL program
  40742. * @param value defines the list of strings representing the varying names
  40743. */
  40744. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  40745. /**
  40746. * Bind a webGL buffer for a transform feedback operation
  40747. * @param value defines the webGL buffer to bind
  40748. */
  40749. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  40750. }
  40751. }
  40752. declare module BABYLON {
  40753. /**
  40754. * Gather the list of clipboard event types as constants.
  40755. */
  40756. export class ClipboardEventTypes {
  40757. /**
  40758. * The clipboard event is fired when a copy command is active (pressed).
  40759. */
  40760. static readonly COPY: number;
  40761. /**
  40762. * The clipboard event is fired when a cut command is active (pressed).
  40763. */
  40764. static readonly CUT: number;
  40765. /**
  40766. * The clipboard event is fired when a paste command is active (pressed).
  40767. */
  40768. static readonly PASTE: number;
  40769. }
  40770. /**
  40771. * This class is used to store clipboard related info for the onClipboardObservable event.
  40772. */
  40773. export class ClipboardInfo {
  40774. /**
  40775. * Defines the type of event (BABYLON.ClipboardEventTypes)
  40776. */
  40777. type: number;
  40778. /**
  40779. * Defines the related dom event
  40780. */
  40781. event: ClipboardEvent;
  40782. /**
  40783. *Creates an instance of ClipboardInfo.
  40784. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  40785. * @param event Defines the related dom event
  40786. */
  40787. constructor(
  40788. /**
  40789. * Defines the type of event (BABYLON.ClipboardEventTypes)
  40790. */
  40791. type: number,
  40792. /**
  40793. * Defines the related dom event
  40794. */
  40795. event: ClipboardEvent);
  40796. /**
  40797. * Get the clipboard event's type from the keycode.
  40798. * @param keyCode Defines the keyCode for the current keyboard event.
  40799. * @return {number}
  40800. */
  40801. static GetTypeFromCharacter(keyCode: number): number;
  40802. }
  40803. }
  40804. declare module BABYLON {
  40805. /**
  40806. * Class used to represent data loading progression
  40807. */
  40808. export class SceneLoaderProgressEvent {
  40809. /** defines if data length to load can be evaluated */
  40810. readonly lengthComputable: boolean;
  40811. /** defines the loaded data length */
  40812. readonly loaded: number;
  40813. /** defines the data length to load */
  40814. readonly total: number;
  40815. /**
  40816. * Create a new progress event
  40817. * @param lengthComputable defines if data length to load can be evaluated
  40818. * @param loaded defines the loaded data length
  40819. * @param total defines the data length to load
  40820. */
  40821. constructor(
  40822. /** defines if data length to load can be evaluated */
  40823. lengthComputable: boolean,
  40824. /** defines the loaded data length */
  40825. loaded: number,
  40826. /** defines the data length to load */
  40827. total: number);
  40828. /**
  40829. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  40830. * @param event defines the source event
  40831. * @returns a new SceneLoaderProgressEvent
  40832. */
  40833. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  40834. }
  40835. /**
  40836. * Interface used by SceneLoader plugins to define supported file extensions
  40837. */
  40838. export interface ISceneLoaderPluginExtensions {
  40839. /**
  40840. * Defines the list of supported extensions
  40841. */
  40842. [extension: string]: {
  40843. isBinary: boolean;
  40844. };
  40845. }
  40846. /**
  40847. * Interface used by SceneLoader plugin factory
  40848. */
  40849. export interface ISceneLoaderPluginFactory {
  40850. /**
  40851. * Defines the name of the factory
  40852. */
  40853. name: string;
  40854. /**
  40855. * Function called to create a new plugin
  40856. * @return the new plugin
  40857. */
  40858. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  40859. /**
  40860. * Boolean indicating if the plugin can direct load specific data
  40861. */
  40862. canDirectLoad?: (data: string) => boolean;
  40863. }
  40864. /**
  40865. * Interface used to define a SceneLoader plugin
  40866. */
  40867. export interface ISceneLoaderPlugin {
  40868. /**
  40869. * The friendly name of this plugin.
  40870. */
  40871. name: string;
  40872. /**
  40873. * The file extensions supported by this plugin.
  40874. */
  40875. extensions: string | ISceneLoaderPluginExtensions;
  40876. /**
  40877. * Import meshes into a scene.
  40878. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40879. * @param scene The scene to import into
  40880. * @param data The data to import
  40881. * @param rootUrl The root url for scene and resources
  40882. * @param meshes The meshes array to import into
  40883. * @param particleSystems The particle systems array to import into
  40884. * @param skeletons The skeletons array to import into
  40885. * @param onError The callback when import fails
  40886. * @returns True if successful or false otherwise
  40887. */
  40888. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  40889. /**
  40890. * Load into a scene.
  40891. * @param scene The scene to load into
  40892. * @param data The data to import
  40893. * @param rootUrl The root url for scene and resources
  40894. * @param onError The callback when import fails
  40895. * @returns true if successful or false otherwise
  40896. */
  40897. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  40898. /**
  40899. * The callback that returns true if the data can be directly loaded.
  40900. */
  40901. canDirectLoad?: (data: string) => boolean;
  40902. /**
  40903. * The callback that allows custom handling of the root url based on the response url.
  40904. */
  40905. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  40906. /**
  40907. * Load into an asset container.
  40908. * @param scene The scene to load into
  40909. * @param data The data to import
  40910. * @param rootUrl The root url for scene and resources
  40911. * @param onError The callback when import fails
  40912. * @returns The loaded asset container
  40913. */
  40914. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  40915. }
  40916. /**
  40917. * Interface used to define an async SceneLoader plugin
  40918. */
  40919. export interface ISceneLoaderPluginAsync {
  40920. /**
  40921. * The friendly name of this plugin.
  40922. */
  40923. name: string;
  40924. /**
  40925. * The file extensions supported by this plugin.
  40926. */
  40927. extensions: string | ISceneLoaderPluginExtensions;
  40928. /**
  40929. * Import meshes into a scene.
  40930. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40931. * @param scene The scene to import into
  40932. * @param data The data to import
  40933. * @param rootUrl The root url for scene and resources
  40934. * @param onProgress The callback when the load progresses
  40935. * @param fileName Defines the name of the file to load
  40936. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  40937. */
  40938. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  40939. meshes: AbstractMesh[];
  40940. particleSystems: IParticleSystem[];
  40941. skeletons: Skeleton[];
  40942. animationGroups: AnimationGroup[];
  40943. }>;
  40944. /**
  40945. * Load into a scene.
  40946. * @param scene The scene to load into
  40947. * @param data The data to import
  40948. * @param rootUrl The root url for scene and resources
  40949. * @param onProgress The callback when the load progresses
  40950. * @param fileName Defines the name of the file to load
  40951. * @returns Nothing
  40952. */
  40953. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  40954. /**
  40955. * The callback that returns true if the data can be directly loaded.
  40956. */
  40957. canDirectLoad?: (data: string) => boolean;
  40958. /**
  40959. * The callback that allows custom handling of the root url based on the response url.
  40960. */
  40961. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  40962. /**
  40963. * Load into an asset container.
  40964. * @param scene The scene to load into
  40965. * @param data The data to import
  40966. * @param rootUrl The root url for scene and resources
  40967. * @param onProgress The callback when the load progresses
  40968. * @param fileName Defines the name of the file to load
  40969. * @returns The loaded asset container
  40970. */
  40971. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  40972. }
  40973. /**
  40974. * Class used to load scene from various file formats using registered plugins
  40975. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  40976. */
  40977. export class SceneLoader {
  40978. /**
  40979. * No logging while loading
  40980. */
  40981. static readonly NO_LOGGING: number;
  40982. /**
  40983. * Minimal logging while loading
  40984. */
  40985. static readonly MINIMAL_LOGGING: number;
  40986. /**
  40987. * Summary logging while loading
  40988. */
  40989. static readonly SUMMARY_LOGGING: number;
  40990. /**
  40991. * Detailled logging while loading
  40992. */
  40993. static readonly DETAILED_LOGGING: number;
  40994. /**
  40995. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  40996. */
  40997. static ForceFullSceneLoadingForIncremental: boolean;
  40998. /**
  40999. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41000. */
  41001. static ShowLoadingScreen: boolean;
  41002. /**
  41003. * Defines the current logging level (while loading the scene)
  41004. * @ignorenaming
  41005. */
  41006. static loggingLevel: number;
  41007. /**
  41008. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41009. */
  41010. static CleanBoneMatrixWeights: boolean;
  41011. /**
  41012. * Event raised when a plugin is used to load a scene
  41013. */
  41014. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41015. private static _registeredPlugins;
  41016. private static _getDefaultPlugin;
  41017. private static _getPluginForExtension;
  41018. private static _getPluginForDirectLoad;
  41019. private static _getPluginForFilename;
  41020. private static _getDirectLoad;
  41021. private static _loadData;
  41022. private static _getFileInfo;
  41023. /**
  41024. * Gets a plugin that can load the given extension
  41025. * @param extension defines the extension to load
  41026. * @returns a plugin or null if none works
  41027. */
  41028. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41029. /**
  41030. * Gets a boolean indicating that the given extension can be loaded
  41031. * @param extension defines the extension to load
  41032. * @returns true if the extension is supported
  41033. */
  41034. static IsPluginForExtensionAvailable(extension: string): boolean;
  41035. /**
  41036. * Adds a new plugin to the list of registered plugins
  41037. * @param plugin defines the plugin to add
  41038. */
  41039. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41040. /**
  41041. * Import meshes into a scene
  41042. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41043. * @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)
  41044. * @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)
  41045. * @param scene the instance of BABYLON.Scene to append to
  41046. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41047. * @param onProgress a callback with a progress event for each file being loaded
  41048. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41049. * @param pluginExtension the extension used to determine the plugin
  41050. * @returns The loaded plugin
  41051. */
  41052. 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>;
  41053. /**
  41054. * Import meshes into a scene
  41055. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41056. * @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)
  41057. * @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)
  41058. * @param scene the instance of BABYLON.Scene to append to
  41059. * @param onProgress a callback with a progress event for each file being loaded
  41060. * @param pluginExtension the extension used to determine the plugin
  41061. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41062. */
  41063. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41064. meshes: AbstractMesh[];
  41065. particleSystems: IParticleSystem[];
  41066. skeletons: Skeleton[];
  41067. animationGroups: AnimationGroup[];
  41068. }>;
  41069. /**
  41070. * Load a scene
  41071. * @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)
  41072. * @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)
  41073. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41074. * @param onSuccess a callback with the scene when import succeeds
  41075. * @param onProgress a callback with a progress event for each file being loaded
  41076. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41077. * @param pluginExtension the extension used to determine the plugin
  41078. * @returns The loaded plugin
  41079. */
  41080. 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>;
  41081. /**
  41082. * Load a scene
  41083. * @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)
  41084. * @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)
  41085. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41086. * @param onProgress a callback with a progress event for each file being loaded
  41087. * @param pluginExtension the extension used to determine the plugin
  41088. * @returns The loaded scene
  41089. */
  41090. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41091. /**
  41092. * Append a scene
  41093. * @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)
  41094. * @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)
  41095. * @param scene is the instance of BABYLON.Scene to append to
  41096. * @param onSuccess a callback with the scene when import succeeds
  41097. * @param onProgress a callback with a progress event for each file being loaded
  41098. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41099. * @param pluginExtension the extension used to determine the plugin
  41100. * @returns The loaded plugin
  41101. */
  41102. 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>;
  41103. /**
  41104. * Append a scene
  41105. * @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)
  41106. * @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)
  41107. * @param scene is the instance of BABYLON.Scene to append to
  41108. * @param onProgress a callback with a progress event for each file being loaded
  41109. * @param pluginExtension the extension used to determine the plugin
  41110. * @returns The given scene
  41111. */
  41112. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41113. /**
  41114. * Load a scene into an asset container
  41115. * @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)
  41116. * @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)
  41117. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41118. * @param onSuccess a callback with the scene when import succeeds
  41119. * @param onProgress a callback with a progress event for each file being loaded
  41120. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41121. * @param pluginExtension the extension used to determine the plugin
  41122. * @returns The loaded plugin
  41123. */
  41124. 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>;
  41125. /**
  41126. * Load a scene into an asset container
  41127. * @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)
  41128. * @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)
  41129. * @param scene is the instance of Scene to append to
  41130. * @param onProgress a callback with a progress event for each file being loaded
  41131. * @param pluginExtension the extension used to determine the plugin
  41132. * @returns The loaded asset container
  41133. */
  41134. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41135. }
  41136. }
  41137. declare module BABYLON {
  41138. /**
  41139. * Google Daydream controller
  41140. */
  41141. export class DaydreamController extends WebVRController {
  41142. /**
  41143. * Base Url for the controller model.
  41144. */
  41145. static MODEL_BASE_URL: string;
  41146. /**
  41147. * File name for the controller model.
  41148. */
  41149. static MODEL_FILENAME: string;
  41150. /**
  41151. * Gamepad Id prefix used to identify Daydream Controller.
  41152. */
  41153. static readonly GAMEPAD_ID_PREFIX: string;
  41154. /**
  41155. * Creates a new DaydreamController from a gamepad
  41156. * @param vrGamepad the gamepad that the controller should be created from
  41157. */
  41158. constructor(vrGamepad: any);
  41159. /**
  41160. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41161. * @param scene scene in which to add meshes
  41162. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41163. */
  41164. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41165. /**
  41166. * Called once for each button that changed state since the last frame
  41167. * @param buttonIdx Which button index changed
  41168. * @param state New state of the button
  41169. * @param changes Which properties on the state changed since last frame
  41170. */
  41171. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41172. }
  41173. }
  41174. declare module BABYLON {
  41175. /**
  41176. * Gear VR Controller
  41177. */
  41178. export class GearVRController extends WebVRController {
  41179. /**
  41180. * Base Url for the controller model.
  41181. */
  41182. static MODEL_BASE_URL: string;
  41183. /**
  41184. * File name for the controller model.
  41185. */
  41186. static MODEL_FILENAME: string;
  41187. /**
  41188. * Gamepad Id prefix used to identify this controller.
  41189. */
  41190. static readonly GAMEPAD_ID_PREFIX: string;
  41191. private readonly _buttonIndexToObservableNameMap;
  41192. /**
  41193. * Creates a new GearVRController from a gamepad
  41194. * @param vrGamepad the gamepad that the controller should be created from
  41195. */
  41196. constructor(vrGamepad: any);
  41197. /**
  41198. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41199. * @param scene scene in which to add meshes
  41200. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41201. */
  41202. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41203. /**
  41204. * Called once for each button that changed state since the last frame
  41205. * @param buttonIdx Which button index changed
  41206. * @param state New state of the button
  41207. * @param changes Which properties on the state changed since last frame
  41208. */
  41209. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41210. }
  41211. }
  41212. declare module BABYLON {
  41213. /**
  41214. * Generic Controller
  41215. */
  41216. export class GenericController extends WebVRController {
  41217. /**
  41218. * Base Url for the controller model.
  41219. */
  41220. static readonly MODEL_BASE_URL: string;
  41221. /**
  41222. * File name for the controller model.
  41223. */
  41224. static readonly MODEL_FILENAME: string;
  41225. /**
  41226. * Creates a new GenericController from a gamepad
  41227. * @param vrGamepad the gamepad that the controller should be created from
  41228. */
  41229. constructor(vrGamepad: any);
  41230. /**
  41231. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41232. * @param scene scene in which to add meshes
  41233. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41234. */
  41235. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41236. /**
  41237. * Called once for each button that changed state since the last frame
  41238. * @param buttonIdx Which button index changed
  41239. * @param state New state of the button
  41240. * @param changes Which properties on the state changed since last frame
  41241. */
  41242. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41243. }
  41244. }
  41245. declare module BABYLON {
  41246. /**
  41247. * Oculus Touch Controller
  41248. */
  41249. export class OculusTouchController extends WebVRController {
  41250. /**
  41251. * Base Url for the controller model.
  41252. */
  41253. static MODEL_BASE_URL: string;
  41254. /**
  41255. * File name for the left controller model.
  41256. */
  41257. static MODEL_LEFT_FILENAME: string;
  41258. /**
  41259. * File name for the right controller model.
  41260. */
  41261. static MODEL_RIGHT_FILENAME: string;
  41262. /**
  41263. * Fired when the secondary trigger on this controller is modified
  41264. */
  41265. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41266. /**
  41267. * Fired when the thumb rest on this controller is modified
  41268. */
  41269. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41270. /**
  41271. * Creates a new OculusTouchController from a gamepad
  41272. * @param vrGamepad the gamepad that the controller should be created from
  41273. */
  41274. constructor(vrGamepad: any);
  41275. /**
  41276. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41277. * @param scene scene in which to add meshes
  41278. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41279. */
  41280. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41281. /**
  41282. * Fired when the A button on this controller is modified
  41283. */
  41284. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41285. /**
  41286. * Fired when the B button on this controller is modified
  41287. */
  41288. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41289. /**
  41290. * Fired when the X button on this controller is modified
  41291. */
  41292. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41293. /**
  41294. * Fired when the Y button on this controller is modified
  41295. */
  41296. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41297. /**
  41298. * Called once for each button that changed state since the last frame
  41299. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41300. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41301. * 2) secondary trigger (same)
  41302. * 3) A (right) X (left), touch, pressed = value
  41303. * 4) B / Y
  41304. * 5) thumb rest
  41305. * @param buttonIdx Which button index changed
  41306. * @param state New state of the button
  41307. * @param changes Which properties on the state changed since last frame
  41308. */
  41309. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41310. }
  41311. }
  41312. declare module BABYLON {
  41313. /**
  41314. * Vive Controller
  41315. */
  41316. export class ViveController extends WebVRController {
  41317. /**
  41318. * Base Url for the controller model.
  41319. */
  41320. static MODEL_BASE_URL: string;
  41321. /**
  41322. * File name for the controller model.
  41323. */
  41324. static MODEL_FILENAME: string;
  41325. /**
  41326. * Creates a new ViveController from a gamepad
  41327. * @param vrGamepad the gamepad that the controller should be created from
  41328. */
  41329. constructor(vrGamepad: any);
  41330. /**
  41331. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41332. * @param scene scene in which to add meshes
  41333. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41334. */
  41335. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41336. /**
  41337. * Fired when the left button on this controller is modified
  41338. */
  41339. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41340. /**
  41341. * Fired when the right button on this controller is modified
  41342. */
  41343. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41344. /**
  41345. * Fired when the menu button on this controller is modified
  41346. */
  41347. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41348. /**
  41349. * Called once for each button that changed state since the last frame
  41350. * Vive mapping:
  41351. * 0: touchpad
  41352. * 1: trigger
  41353. * 2: left AND right buttons
  41354. * 3: menu button
  41355. * @param buttonIdx Which button index changed
  41356. * @param state New state of the button
  41357. * @param changes Which properties on the state changed since last frame
  41358. */
  41359. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41360. }
  41361. }
  41362. declare module BABYLON {
  41363. /**
  41364. * Defines the WindowsMotionController object that the state of the windows motion controller
  41365. */
  41366. export class WindowsMotionController extends WebVRController {
  41367. /**
  41368. * The base url used to load the left and right controller models
  41369. */
  41370. static MODEL_BASE_URL: string;
  41371. /**
  41372. * The name of the left controller model file
  41373. */
  41374. static MODEL_LEFT_FILENAME: string;
  41375. /**
  41376. * The name of the right controller model file
  41377. */
  41378. static MODEL_RIGHT_FILENAME: string;
  41379. /**
  41380. * The controller name prefix for this controller type
  41381. */
  41382. static readonly GAMEPAD_ID_PREFIX: string;
  41383. /**
  41384. * The controller id pattern for this controller type
  41385. */
  41386. private static readonly GAMEPAD_ID_PATTERN;
  41387. private _loadedMeshInfo;
  41388. private readonly _mapping;
  41389. /**
  41390. * Fired when the trackpad on this controller is clicked
  41391. */
  41392. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41393. /**
  41394. * Fired when the trackpad on this controller is modified
  41395. */
  41396. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41397. /**
  41398. * The current x and y values of this controller's trackpad
  41399. */
  41400. trackpad: StickValues;
  41401. /**
  41402. * Creates a new WindowsMotionController from a gamepad
  41403. * @param vrGamepad the gamepad that the controller should be created from
  41404. */
  41405. constructor(vrGamepad: any);
  41406. /**
  41407. * Fired when the trigger on this controller is modified
  41408. */
  41409. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41410. /**
  41411. * Fired when the menu button on this controller is modified
  41412. */
  41413. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41414. /**
  41415. * Fired when the grip button on this controller is modified
  41416. */
  41417. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41418. /**
  41419. * Fired when the thumbstick button on this controller is modified
  41420. */
  41421. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41422. /**
  41423. * Fired when the touchpad button on this controller is modified
  41424. */
  41425. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41426. /**
  41427. * Fired when the touchpad values on this controller are modified
  41428. */
  41429. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41430. private _updateTrackpad;
  41431. /**
  41432. * Called once per frame by the engine.
  41433. */
  41434. update(): void;
  41435. /**
  41436. * Called once for each button that changed state since the last frame
  41437. * @param buttonIdx Which button index changed
  41438. * @param state New state of the button
  41439. * @param changes Which properties on the state changed since last frame
  41440. */
  41441. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41442. /**
  41443. * Moves the buttons on the controller mesh based on their current state
  41444. * @param buttonName the name of the button to move
  41445. * @param buttonValue the value of the button which determines the buttons new position
  41446. */
  41447. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41448. /**
  41449. * Moves the axis on the controller mesh based on its current state
  41450. * @param axis the index of the axis
  41451. * @param axisValue the value of the axis which determines the meshes new position
  41452. * @hidden
  41453. */
  41454. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41455. /**
  41456. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41457. * @param scene scene in which to add meshes
  41458. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41459. */
  41460. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41461. /**
  41462. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41463. * can be transformed by button presses and axes values, based on this._mapping.
  41464. *
  41465. * @param scene scene in which the meshes exist
  41466. * @param meshes list of meshes that make up the controller model to process
  41467. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41468. */
  41469. private processModel;
  41470. private createMeshInfo;
  41471. /**
  41472. * Gets the ray of the controller in the direction the controller is pointing
  41473. * @param length the length the resulting ray should be
  41474. * @returns a ray in the direction the controller is pointing
  41475. */
  41476. getForwardRay(length?: number): Ray;
  41477. /**
  41478. * Disposes of the controller
  41479. */
  41480. dispose(): void;
  41481. }
  41482. }
  41483. declare module BABYLON {
  41484. /**
  41485. * Single axis scale gizmo
  41486. */
  41487. export class AxisScaleGizmo extends Gizmo {
  41488. private _coloredMaterial;
  41489. /**
  41490. * Drag behavior responsible for the gizmos dragging interactions
  41491. */
  41492. dragBehavior: PointerDragBehavior;
  41493. private _pointerObserver;
  41494. /**
  41495. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41496. */
  41497. snapDistance: number;
  41498. /**
  41499. * Event that fires each time the gizmo snaps to a new location.
  41500. * * snapDistance is the the change in distance
  41501. */
  41502. onSnapObservable: Observable<{
  41503. snapDistance: number;
  41504. }>;
  41505. /**
  41506. * If the scaling operation should be done on all axis (default: false)
  41507. */
  41508. uniformScaling: boolean;
  41509. /**
  41510. * Creates an AxisScaleGizmo
  41511. * @param gizmoLayer The utility layer the gizmo will be added to
  41512. * @param dragAxis The axis which the gizmo will be able to scale on
  41513. * @param color The color of the gizmo
  41514. */
  41515. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41516. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41517. /**
  41518. * Disposes of the gizmo
  41519. */
  41520. dispose(): void;
  41521. /**
  41522. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41523. * @param mesh The mesh to replace the default mesh of the gizmo
  41524. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  41525. */
  41526. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  41527. }
  41528. }
  41529. declare module BABYLON {
  41530. /**
  41531. * Bounding box gizmo
  41532. */
  41533. export class BoundingBoxGizmo extends Gizmo {
  41534. private _lineBoundingBox;
  41535. private _rotateSpheresParent;
  41536. private _scaleBoxesParent;
  41537. private _boundingDimensions;
  41538. private _renderObserver;
  41539. private _pointerObserver;
  41540. private _scaleDragSpeed;
  41541. private _tmpQuaternion;
  41542. private _tmpVector;
  41543. private _tmpRotationMatrix;
  41544. /**
  41545. * 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)
  41546. */
  41547. ignoreChildren: boolean;
  41548. /**
  41549. * 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)
  41550. */
  41551. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  41552. /**
  41553. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  41554. */
  41555. rotationSphereSize: number;
  41556. /**
  41557. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  41558. */
  41559. scaleBoxSize: number;
  41560. /**
  41561. * 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)
  41562. */
  41563. fixedDragMeshScreenSize: boolean;
  41564. /**
  41565. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  41566. */
  41567. fixedDragMeshScreenSizeDistanceFactor: number;
  41568. /**
  41569. * Fired when a rotation sphere or scale box is dragged
  41570. */
  41571. onDragStartObservable: Observable<{}>;
  41572. /**
  41573. * Fired when a scale box is dragged
  41574. */
  41575. onScaleBoxDragObservable: Observable<{}>;
  41576. /**
  41577. * Fired when a scale box drag is ended
  41578. */
  41579. onScaleBoxDragEndObservable: Observable<{}>;
  41580. /**
  41581. * Fired when a rotation sphere is dragged
  41582. */
  41583. onRotationSphereDragObservable: Observable<{}>;
  41584. /**
  41585. * Fired when a rotation sphere drag is ended
  41586. */
  41587. onRotationSphereDragEndObservable: Observable<{}>;
  41588. /**
  41589. * 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)
  41590. */
  41591. scalePivot: Nullable<Vector3>;
  41592. private _anchorMesh;
  41593. private _existingMeshScale;
  41594. private _dragMesh;
  41595. private pointerDragBehavior;
  41596. private coloredMaterial;
  41597. private hoverColoredMaterial;
  41598. /**
  41599. * Sets the color of the bounding box gizmo
  41600. * @param color the color to set
  41601. */
  41602. setColor(color: Color3): void;
  41603. /**
  41604. * Creates an BoundingBoxGizmo
  41605. * @param gizmoLayer The utility layer the gizmo will be added to
  41606. * @param color The color of the gizmo
  41607. */
  41608. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41609. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41610. private _selectNode;
  41611. /**
  41612. * Updates the bounding box information for the Gizmo
  41613. */
  41614. updateBoundingBox(): void;
  41615. private _updateRotationSpheres;
  41616. private _updateScaleBoxes;
  41617. /**
  41618. * Enables rotation on the specified axis and disables rotation on the others
  41619. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  41620. */
  41621. setEnabledRotationAxis(axis: string): void;
  41622. /**
  41623. * Enables/disables scaling
  41624. * @param enable if scaling should be enabled
  41625. */
  41626. setEnabledScaling(enable: boolean): void;
  41627. private _updateDummy;
  41628. /**
  41629. * Enables a pointer drag behavior on the bounding box of the gizmo
  41630. */
  41631. enableDragBehavior(): void;
  41632. /**
  41633. * Disposes of the gizmo
  41634. */
  41635. dispose(): void;
  41636. /**
  41637. * 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)
  41638. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  41639. * @returns the bounding box mesh with the passed in mesh as a child
  41640. */
  41641. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  41642. /**
  41643. * CustomMeshes are not supported by this gizmo
  41644. * @param mesh The mesh to replace the default mesh of the gizmo
  41645. */
  41646. setCustomMesh(mesh: Mesh): void;
  41647. }
  41648. }
  41649. declare module BABYLON {
  41650. /**
  41651. * Single plane rotation gizmo
  41652. */
  41653. export class PlaneRotationGizmo extends Gizmo {
  41654. /**
  41655. * Drag behavior responsible for the gizmos dragging interactions
  41656. */
  41657. dragBehavior: PointerDragBehavior;
  41658. private _pointerObserver;
  41659. /**
  41660. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  41661. */
  41662. snapDistance: number;
  41663. /**
  41664. * Event that fires each time the gizmo snaps to a new location.
  41665. * * snapDistance is the the change in distance
  41666. */
  41667. onSnapObservable: Observable<{
  41668. snapDistance: number;
  41669. }>;
  41670. /**
  41671. * Creates a PlaneRotationGizmo
  41672. * @param gizmoLayer The utility layer the gizmo will be added to
  41673. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  41674. * @param color The color of the gizmo
  41675. * @param tessellation Amount of tessellation to be used when creating rotation circles
  41676. */
  41677. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  41678. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41679. /**
  41680. * Disposes of the gizmo
  41681. */
  41682. dispose(): void;
  41683. }
  41684. }
  41685. declare module BABYLON {
  41686. /**
  41687. * Gizmo that enables rotating a mesh along 3 axis
  41688. */
  41689. export class RotationGizmo extends Gizmo {
  41690. /**
  41691. * Internal gizmo used for interactions on the x axis
  41692. */
  41693. xGizmo: PlaneRotationGizmo;
  41694. /**
  41695. * Internal gizmo used for interactions on the y axis
  41696. */
  41697. yGizmo: PlaneRotationGizmo;
  41698. /**
  41699. * Internal gizmo used for interactions on the z axis
  41700. */
  41701. zGizmo: PlaneRotationGizmo;
  41702. /** Fires an event when any of it's sub gizmos are dragged */
  41703. onDragStartObservable: Observable<{}>;
  41704. /** Fires an event when any of it's sub gizmos are released from dragging */
  41705. onDragEndObservable: Observable<{}>;
  41706. attachedMesh: Nullable<AbstractMesh>;
  41707. /**
  41708. * Creates a RotationGizmo
  41709. * @param gizmoLayer The utility layer the gizmo will be added to
  41710. * @param tessellation Amount of tessellation to be used when creating rotation circles
  41711. */
  41712. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  41713. updateGizmoRotationToMatchAttachedMesh: boolean;
  41714. /**
  41715. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41716. */
  41717. snapDistance: number;
  41718. /**
  41719. * Ratio for the scale of the gizmo (Default: 1)
  41720. */
  41721. scaleRatio: number;
  41722. /**
  41723. * Disposes of the gizmo
  41724. */
  41725. dispose(): void;
  41726. /**
  41727. * CustomMeshes are not supported by this gizmo
  41728. * @param mesh The mesh to replace the default mesh of the gizmo
  41729. */
  41730. setCustomMesh(mesh: Mesh): void;
  41731. }
  41732. }
  41733. declare module BABYLON {
  41734. /**
  41735. * Gizmo that enables dragging a mesh along 3 axis
  41736. */
  41737. export class PositionGizmo extends Gizmo {
  41738. /**
  41739. * Internal gizmo used for interactions on the x axis
  41740. */
  41741. xGizmo: AxisDragGizmo;
  41742. /**
  41743. * Internal gizmo used for interactions on the y axis
  41744. */
  41745. yGizmo: AxisDragGizmo;
  41746. /**
  41747. * Internal gizmo used for interactions on the z axis
  41748. */
  41749. zGizmo: AxisDragGizmo;
  41750. /** Fires an event when any of it's sub gizmos are dragged */
  41751. onDragStartObservable: Observable<{}>;
  41752. /** Fires an event when any of it's sub gizmos are released from dragging */
  41753. onDragEndObservable: Observable<{}>;
  41754. attachedMesh: Nullable<AbstractMesh>;
  41755. /**
  41756. * Creates a PositionGizmo
  41757. * @param gizmoLayer The utility layer the gizmo will be added to
  41758. */
  41759. constructor(gizmoLayer?: UtilityLayerRenderer);
  41760. updateGizmoRotationToMatchAttachedMesh: boolean;
  41761. /**
  41762. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41763. */
  41764. snapDistance: number;
  41765. /**
  41766. * Ratio for the scale of the gizmo (Default: 1)
  41767. */
  41768. scaleRatio: number;
  41769. /**
  41770. * Disposes of the gizmo
  41771. */
  41772. dispose(): void;
  41773. /**
  41774. * CustomMeshes are not supported by this gizmo
  41775. * @param mesh The mesh to replace the default mesh of the gizmo
  41776. */
  41777. setCustomMesh(mesh: Mesh): void;
  41778. }
  41779. }
  41780. declare module BABYLON {
  41781. /**
  41782. * Class containing static functions to help procedurally build meshes
  41783. */
  41784. export class PolyhedronBuilder {
  41785. /**
  41786. * Creates a polyhedron mesh
  41787. * * 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
  41788. * * The parameter `size` (positive float, default 1) sets the polygon size
  41789. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  41790. * * 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`
  41791. * * 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
  41792. * * 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)`)
  41793. * * 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
  41794. * * 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
  41795. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41796. * * If you create a double-sided mesh, you can choose what parts of 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
  41797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41798. * @param name defines the name of the mesh
  41799. * @param options defines the options used to create the mesh
  41800. * @param scene defines the hosting scene
  41801. * @returns the polyhedron mesh
  41802. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  41803. */
  41804. static CreatePolyhedron(name: string, options: {
  41805. type?: number;
  41806. size?: number;
  41807. sizeX?: number;
  41808. sizeY?: number;
  41809. sizeZ?: number;
  41810. custom?: any;
  41811. faceUV?: Vector4[];
  41812. faceColors?: Color4[];
  41813. flat?: boolean;
  41814. updatable?: boolean;
  41815. sideOrientation?: number;
  41816. frontUVs?: Vector4;
  41817. backUVs?: Vector4;
  41818. }, scene?: Nullable<Scene>): Mesh;
  41819. }
  41820. }
  41821. declare module BABYLON {
  41822. /**
  41823. * Gizmo that enables scaling a mesh along 3 axis
  41824. */
  41825. export class ScaleGizmo extends Gizmo {
  41826. /**
  41827. * Internal gizmo used for interactions on the x axis
  41828. */
  41829. xGizmo: AxisScaleGizmo;
  41830. /**
  41831. * Internal gizmo used for interactions on the y axis
  41832. */
  41833. yGizmo: AxisScaleGizmo;
  41834. /**
  41835. * Internal gizmo used for interactions on the z axis
  41836. */
  41837. zGizmo: AxisScaleGizmo;
  41838. /**
  41839. * Internal gizmo used to scale all axis equally
  41840. */
  41841. uniformScaleGizmo: AxisScaleGizmo;
  41842. /** Fires an event when any of it's sub gizmos are dragged */
  41843. onDragStartObservable: Observable<{}>;
  41844. /** Fires an event when any of it's sub gizmos are released from dragging */
  41845. onDragEndObservable: Observable<{}>;
  41846. attachedMesh: Nullable<AbstractMesh>;
  41847. /**
  41848. * Creates a ScaleGizmo
  41849. * @param gizmoLayer The utility layer the gizmo will be added to
  41850. */
  41851. constructor(gizmoLayer?: UtilityLayerRenderer);
  41852. updateGizmoRotationToMatchAttachedMesh: boolean;
  41853. /**
  41854. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41855. */
  41856. snapDistance: number;
  41857. /**
  41858. * Ratio for the scale of the gizmo (Default: 1)
  41859. */
  41860. scaleRatio: number;
  41861. /**
  41862. * Disposes of the gizmo
  41863. */
  41864. dispose(): void;
  41865. }
  41866. }
  41867. declare module BABYLON {
  41868. /**
  41869. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  41870. */
  41871. export class GizmoManager implements IDisposable {
  41872. private scene;
  41873. /**
  41874. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  41875. */
  41876. gizmos: {
  41877. positionGizmo: Nullable<PositionGizmo>;
  41878. rotationGizmo: Nullable<RotationGizmo>;
  41879. scaleGizmo: Nullable<ScaleGizmo>;
  41880. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  41881. };
  41882. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  41883. clearGizmoOnEmptyPointerEvent: boolean;
  41884. /** Fires an event when the manager is attached to a mesh */
  41885. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  41886. private _gizmosEnabled;
  41887. private _pointerObserver;
  41888. private _attachedMesh;
  41889. private _boundingBoxColor;
  41890. private _defaultUtilityLayer;
  41891. private _defaultKeepDepthUtilityLayer;
  41892. /**
  41893. * When bounding box gizmo is enabled, this can be used to track drag/end events
  41894. */
  41895. boundingBoxDragBehavior: SixDofDragBehavior;
  41896. /**
  41897. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  41898. */
  41899. attachableMeshes: Nullable<Array<AbstractMesh>>;
  41900. /**
  41901. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  41902. */
  41903. usePointerToAttachGizmos: boolean;
  41904. /**
  41905. * Instatiates a gizmo manager
  41906. * @param scene the scene to overlay the gizmos on top of
  41907. */
  41908. constructor(scene: Scene);
  41909. /**
  41910. * Attaches a set of gizmos to the specified mesh
  41911. * @param mesh The mesh the gizmo's should be attached to
  41912. */
  41913. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  41914. /**
  41915. * If the position gizmo is enabled
  41916. */
  41917. positionGizmoEnabled: boolean;
  41918. /**
  41919. * If the rotation gizmo is enabled
  41920. */
  41921. rotationGizmoEnabled: boolean;
  41922. /**
  41923. * If the scale gizmo is enabled
  41924. */
  41925. scaleGizmoEnabled: boolean;
  41926. /**
  41927. * If the boundingBox gizmo is enabled
  41928. */
  41929. boundingBoxGizmoEnabled: boolean;
  41930. /**
  41931. * Disposes of the gizmo manager
  41932. */
  41933. dispose(): void;
  41934. }
  41935. }
  41936. declare module BABYLON {
  41937. /**
  41938. * A directional light is defined by a direction (what a surprise!).
  41939. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  41940. * 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.
  41941. * Documentation: https://doc.babylonjs.com/babylon101/lights
  41942. */
  41943. export class DirectionalLight extends ShadowLight {
  41944. private _shadowFrustumSize;
  41945. /**
  41946. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  41947. */
  41948. /**
  41949. * Specifies a fix frustum size for the shadow generation.
  41950. */
  41951. shadowFrustumSize: number;
  41952. private _shadowOrthoScale;
  41953. /**
  41954. * Gets the shadow projection scale against the optimal computed one.
  41955. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  41956. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  41957. */
  41958. /**
  41959. * Sets the shadow projection scale against the optimal computed one.
  41960. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  41961. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  41962. */
  41963. shadowOrthoScale: number;
  41964. /**
  41965. * Automatically compute the projection matrix to best fit (including all the casters)
  41966. * on each frame.
  41967. */
  41968. autoUpdateExtends: boolean;
  41969. private _orthoLeft;
  41970. private _orthoRight;
  41971. private _orthoTop;
  41972. private _orthoBottom;
  41973. /**
  41974. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  41975. * The directional light is emitted from everywhere in the given direction.
  41976. * It can cast shadows.
  41977. * Documentation : https://doc.babylonjs.com/babylon101/lights
  41978. * @param name The friendly name of the light
  41979. * @param direction The direction of the light
  41980. * @param scene The scene the light belongs to
  41981. */
  41982. constructor(name: string, direction: Vector3, scene: Scene);
  41983. /**
  41984. * Returns the string "DirectionalLight".
  41985. * @return The class name
  41986. */
  41987. getClassName(): string;
  41988. /**
  41989. * Returns the integer 1.
  41990. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  41991. */
  41992. getTypeID(): number;
  41993. /**
  41994. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  41995. * Returns the DirectionalLight Shadow projection matrix.
  41996. */
  41997. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  41998. /**
  41999. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  42000. * Returns the DirectionalLight Shadow projection matrix.
  42001. */
  42002. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  42003. /**
  42004. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  42005. * Returns the DirectionalLight Shadow projection matrix.
  42006. */
  42007. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42008. protected _buildUniformLayout(): void;
  42009. /**
  42010. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  42011. * @param effect The effect to update
  42012. * @param lightIndex The index of the light in the effect to update
  42013. * @returns The directional light
  42014. */
  42015. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  42016. /**
  42017. * Gets the minZ used for shadow according to both the scene and the light.
  42018. *
  42019. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42020. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42021. * @param activeCamera The camera we are returning the min for
  42022. * @returns the depth min z
  42023. */
  42024. getDepthMinZ(activeCamera: Camera): number;
  42025. /**
  42026. * Gets the maxZ used for shadow according to both the scene and the light.
  42027. *
  42028. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42029. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42030. * @param activeCamera The camera we are returning the max for
  42031. * @returns the depth max z
  42032. */
  42033. getDepthMaxZ(activeCamera: Camera): number;
  42034. /**
  42035. * Prepares the list of defines specific to the light type.
  42036. * @param defines the list of defines
  42037. * @param lightIndex defines the index of the light for the effect
  42038. */
  42039. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42040. }
  42041. }
  42042. declare module BABYLON {
  42043. /**
  42044. * Class containing static functions to help procedurally build meshes
  42045. */
  42046. export class HemisphereBuilder {
  42047. /**
  42048. * Creates a hemisphere mesh
  42049. * @param name defines the name of the mesh
  42050. * @param options defines the options used to create the mesh
  42051. * @param scene defines the hosting scene
  42052. * @returns the hemisphere mesh
  42053. */
  42054. static CreateHemisphere(name: string, options: {
  42055. segments?: number;
  42056. diameter?: number;
  42057. sideOrientation?: number;
  42058. }, scene: any): Mesh;
  42059. }
  42060. }
  42061. declare module BABYLON {
  42062. /**
  42063. * A spot light is defined by a position, a direction, an angle, and an exponent.
  42064. * These values define a cone of light starting from the position, emitting toward the direction.
  42065. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  42066. * and the exponent defines the speed of the decay of the light with distance (reach).
  42067. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42068. */
  42069. export class SpotLight extends ShadowLight {
  42070. private _angle;
  42071. private _innerAngle;
  42072. private _cosHalfAngle;
  42073. private _lightAngleScale;
  42074. private _lightAngleOffset;
  42075. /**
  42076. * Gets the cone angle of the spot light in Radians.
  42077. */
  42078. /**
  42079. * Sets the cone angle of the spot light in Radians.
  42080. */
  42081. angle: number;
  42082. /**
  42083. * Only used in gltf falloff mode, this defines the angle where
  42084. * the directional falloff will start before cutting at angle which could be seen
  42085. * as outer angle.
  42086. */
  42087. /**
  42088. * Only used in gltf falloff mode, this defines the angle where
  42089. * the directional falloff will start before cutting at angle which could be seen
  42090. * as outer angle.
  42091. */
  42092. innerAngle: number;
  42093. private _shadowAngleScale;
  42094. /**
  42095. * Allows scaling the angle of the light for shadow generation only.
  42096. */
  42097. /**
  42098. * Allows scaling the angle of the light for shadow generation only.
  42099. */
  42100. shadowAngleScale: number;
  42101. /**
  42102. * The light decay speed with the distance from the emission spot.
  42103. */
  42104. exponent: number;
  42105. private _projectionTextureMatrix;
  42106. /**
  42107. * Allows reading the projecton texture
  42108. */
  42109. readonly projectionTextureMatrix: Matrix;
  42110. protected _projectionTextureLightNear: number;
  42111. /**
  42112. * Gets the near clip of the Spotlight for texture projection.
  42113. */
  42114. /**
  42115. * Sets the near clip of the Spotlight for texture projection.
  42116. */
  42117. projectionTextureLightNear: number;
  42118. protected _projectionTextureLightFar: number;
  42119. /**
  42120. * Gets the far clip of the Spotlight for texture projection.
  42121. */
  42122. /**
  42123. * Sets the far clip of the Spotlight for texture projection.
  42124. */
  42125. projectionTextureLightFar: number;
  42126. protected _projectionTextureUpDirection: Vector3;
  42127. /**
  42128. * Gets the Up vector of the Spotlight for texture projection.
  42129. */
  42130. /**
  42131. * Sets the Up vector of the Spotlight for texture projection.
  42132. */
  42133. projectionTextureUpDirection: Vector3;
  42134. private _projectionTexture;
  42135. /**
  42136. * Gets the projection texture of the light.
  42137. */
  42138. /**
  42139. * Sets the projection texture of the light.
  42140. */
  42141. projectionTexture: Nullable<BaseTexture>;
  42142. private _projectionTextureViewLightDirty;
  42143. private _projectionTextureProjectionLightDirty;
  42144. private _projectionTextureDirty;
  42145. private _projectionTextureViewTargetVector;
  42146. private _projectionTextureViewLightMatrix;
  42147. private _projectionTextureProjectionLightMatrix;
  42148. private _projectionTextureScalingMatrix;
  42149. /**
  42150. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  42151. * It can cast shadows.
  42152. * Documentation : https://doc.babylonjs.com/babylon101/lights
  42153. * @param name The light friendly name
  42154. * @param position The position of the spot light in the scene
  42155. * @param direction The direction of the light in the scene
  42156. * @param angle The cone angle of the light in Radians
  42157. * @param exponent The light decay speed with the distance from the emission spot
  42158. * @param scene The scene the lights belongs to
  42159. */
  42160. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  42161. /**
  42162. * Returns the string "SpotLight".
  42163. * @returns the class name
  42164. */
  42165. getClassName(): string;
  42166. /**
  42167. * Returns the integer 2.
  42168. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  42169. */
  42170. getTypeID(): number;
  42171. /**
  42172. * Overrides the direction setter to recompute the projection texture view light Matrix.
  42173. */
  42174. protected _setDirection(value: Vector3): void;
  42175. /**
  42176. * Overrides the position setter to recompute the projection texture view light Matrix.
  42177. */
  42178. protected _setPosition(value: Vector3): void;
  42179. /**
  42180. * 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.
  42181. * Returns the SpotLight.
  42182. */
  42183. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42184. protected _computeProjectionTextureViewLightMatrix(): void;
  42185. protected _computeProjectionTextureProjectionLightMatrix(): void;
  42186. /**
  42187. * Main function for light texture projection matrix computing.
  42188. */
  42189. protected _computeProjectionTextureMatrix(): void;
  42190. protected _buildUniformLayout(): void;
  42191. private _computeAngleValues;
  42192. /**
  42193. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  42194. * @param effect The effect to update
  42195. * @param lightIndex The index of the light in the effect to update
  42196. * @returns The spot light
  42197. */
  42198. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  42199. /**
  42200. * Disposes the light and the associated resources.
  42201. */
  42202. dispose(): void;
  42203. /**
  42204. * Prepares the list of defines specific to the light type.
  42205. * @param defines the list of defines
  42206. * @param lightIndex defines the index of the light for the effect
  42207. */
  42208. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42209. }
  42210. }
  42211. declare module BABYLON {
  42212. /**
  42213. * Gizmo that enables viewing a light
  42214. */
  42215. export class LightGizmo extends Gizmo {
  42216. private _lightMesh;
  42217. private _material;
  42218. /**
  42219. * Creates a LightGizmo
  42220. * @param gizmoLayer The utility layer the gizmo will be added to
  42221. */
  42222. constructor(gizmoLayer?: UtilityLayerRenderer);
  42223. private _light;
  42224. /**
  42225. * The light that the gizmo is attached to
  42226. */
  42227. light: Nullable<Light>;
  42228. /**
  42229. * @hidden
  42230. * Updates the gizmo to match the attached mesh's position/rotation
  42231. */
  42232. protected _update(): void;
  42233. private static _Scale;
  42234. /**
  42235. * Creates the lines for a light mesh
  42236. */
  42237. private static _createLightLines;
  42238. private static _CreateHemisphericLightMesh;
  42239. private static _CreatePointLightMesh;
  42240. private static _CreateSpotLightMesh;
  42241. private static _CreateDirectionalLightMesh;
  42242. }
  42243. }
  42244. declare module BABYLON {
  42245. /** @hidden */
  42246. export var backgroundFragmentDeclaration: {
  42247. name: string;
  42248. shader: string;
  42249. };
  42250. }
  42251. declare module BABYLON {
  42252. /** @hidden */
  42253. export var backgroundUboDeclaration: {
  42254. name: string;
  42255. shader: string;
  42256. };
  42257. }
  42258. declare module BABYLON {
  42259. /** @hidden */
  42260. export var backgroundPixelShader: {
  42261. name: string;
  42262. shader: string;
  42263. };
  42264. }
  42265. declare module BABYLON {
  42266. /** @hidden */
  42267. export var backgroundVertexDeclaration: {
  42268. name: string;
  42269. shader: string;
  42270. };
  42271. }
  42272. declare module BABYLON {
  42273. /** @hidden */
  42274. export var backgroundVertexShader: {
  42275. name: string;
  42276. shader: string;
  42277. };
  42278. }
  42279. declare module BABYLON {
  42280. /**
  42281. * Background material used to create an efficient environement around your scene.
  42282. */
  42283. export class BackgroundMaterial extends PushMaterial {
  42284. /**
  42285. * Standard reflectance value at parallel view angle.
  42286. */
  42287. static StandardReflectance0: number;
  42288. /**
  42289. * Standard reflectance value at grazing angle.
  42290. */
  42291. static StandardReflectance90: number;
  42292. protected _primaryColor: Color3;
  42293. /**
  42294. * Key light Color (multiply against the environement texture)
  42295. */
  42296. primaryColor: Color3;
  42297. protected __perceptualColor: Nullable<Color3>;
  42298. /**
  42299. * Experimental Internal Use Only.
  42300. *
  42301. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  42302. * This acts as a helper to set the primary color to a more "human friendly" value.
  42303. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  42304. * output color as close as possible from the chosen value.
  42305. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  42306. * part of lighting setup.)
  42307. */ perceptualColor: Nullable<Color3>;
  42308. protected _primaryColorShadowLevel: float;
  42309. /**
  42310. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  42311. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  42312. */
  42313. primaryColorShadowLevel: float;
  42314. protected _primaryColorHighlightLevel: float;
  42315. /**
  42316. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  42317. * The primary color is used at the level chosen to define what the white area would look.
  42318. */
  42319. primaryColorHighlightLevel: float;
  42320. protected _reflectionTexture: Nullable<BaseTexture>;
  42321. /**
  42322. * Reflection Texture used in the material.
  42323. * Should be author in a specific way for the best result (refer to the documentation).
  42324. */
  42325. reflectionTexture: Nullable<BaseTexture>;
  42326. protected _reflectionBlur: float;
  42327. /**
  42328. * Reflection Texture level of blur.
  42329. *
  42330. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  42331. * texture twice.
  42332. */
  42333. reflectionBlur: float;
  42334. protected _diffuseTexture: Nullable<BaseTexture>;
  42335. /**
  42336. * Diffuse Texture used in the material.
  42337. * Should be author in a specific way for the best result (refer to the documentation).
  42338. */
  42339. diffuseTexture: Nullable<BaseTexture>;
  42340. protected _shadowLights: Nullable<IShadowLight[]>;
  42341. /**
  42342. * Specify the list of lights casting shadow on the material.
  42343. * All scene shadow lights will be included if null.
  42344. */
  42345. shadowLights: Nullable<IShadowLight[]>;
  42346. protected _shadowLevel: float;
  42347. /**
  42348. * Helps adjusting the shadow to a softer level if required.
  42349. * 0 means black shadows and 1 means no shadows.
  42350. */
  42351. shadowLevel: float;
  42352. protected _sceneCenter: Vector3;
  42353. /**
  42354. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  42355. * It is usually zero but might be interesting to modify according to your setup.
  42356. */
  42357. sceneCenter: Vector3;
  42358. protected _opacityFresnel: boolean;
  42359. /**
  42360. * This helps specifying that the material is falling off to the sky box at grazing angle.
  42361. * This helps ensuring a nice transition when the camera goes under the ground.
  42362. */
  42363. opacityFresnel: boolean;
  42364. protected _reflectionFresnel: boolean;
  42365. /**
  42366. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  42367. * This helps adding a mirror texture on the ground.
  42368. */
  42369. reflectionFresnel: boolean;
  42370. protected _reflectionFalloffDistance: number;
  42371. /**
  42372. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  42373. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  42374. */
  42375. reflectionFalloffDistance: number;
  42376. protected _reflectionAmount: number;
  42377. /**
  42378. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  42379. */
  42380. reflectionAmount: number;
  42381. protected _reflectionReflectance0: number;
  42382. /**
  42383. * This specifies the weight of the reflection at grazing angle.
  42384. */
  42385. reflectionReflectance0: number;
  42386. protected _reflectionReflectance90: number;
  42387. /**
  42388. * This specifies the weight of the reflection at a perpendicular point of view.
  42389. */
  42390. reflectionReflectance90: number;
  42391. /**
  42392. * Sets the reflection reflectance fresnel values according to the default standard
  42393. * empirically know to work well :-)
  42394. */
  42395. reflectionStandardFresnelWeight: number;
  42396. protected _useRGBColor: boolean;
  42397. /**
  42398. * Helps to directly use the maps channels instead of their level.
  42399. */
  42400. useRGBColor: boolean;
  42401. protected _enableNoise: boolean;
  42402. /**
  42403. * This helps reducing the banding effect that could occur on the background.
  42404. */
  42405. enableNoise: boolean;
  42406. /**
  42407. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  42408. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  42409. * Recommended to be keep at 1.0 except for special cases.
  42410. */
  42411. fovMultiplier: number;
  42412. private _fovMultiplier;
  42413. /**
  42414. * Enable the FOV adjustment feature controlled by fovMultiplier.
  42415. */
  42416. useEquirectangularFOV: boolean;
  42417. private _maxSimultaneousLights;
  42418. /**
  42419. * Number of Simultaneous lights allowed on the material.
  42420. */
  42421. maxSimultaneousLights: int;
  42422. /**
  42423. * Default configuration related to image processing available in the Background Material.
  42424. */
  42425. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42426. /**
  42427. * Keep track of the image processing observer to allow dispose and replace.
  42428. */
  42429. private _imageProcessingObserver;
  42430. /**
  42431. * Attaches a new image processing configuration to the PBR Material.
  42432. * @param configuration (if null the scene configuration will be use)
  42433. */
  42434. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42435. /**
  42436. * Gets the image processing configuration used either in this material.
  42437. */
  42438. /**
  42439. * Sets the Default image processing configuration used either in the this material.
  42440. *
  42441. * If sets to null, the scene one is in use.
  42442. */
  42443. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  42444. /**
  42445. * Gets wether the color curves effect is enabled.
  42446. */
  42447. /**
  42448. * Sets wether the color curves effect is enabled.
  42449. */
  42450. cameraColorCurvesEnabled: boolean;
  42451. /**
  42452. * Gets wether the color grading effect is enabled.
  42453. */
  42454. /**
  42455. * Gets wether the color grading effect is enabled.
  42456. */
  42457. cameraColorGradingEnabled: boolean;
  42458. /**
  42459. * Gets wether tonemapping is enabled or not.
  42460. */
  42461. /**
  42462. * Sets wether tonemapping is enabled or not
  42463. */
  42464. cameraToneMappingEnabled: boolean;
  42465. /**
  42466. * The camera exposure used on this material.
  42467. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42468. * This corresponds to a photographic exposure.
  42469. */
  42470. /**
  42471. * The camera exposure used on this material.
  42472. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42473. * This corresponds to a photographic exposure.
  42474. */
  42475. cameraExposure: float;
  42476. /**
  42477. * Gets The camera contrast used on this material.
  42478. */
  42479. /**
  42480. * Sets The camera contrast used on this material.
  42481. */
  42482. cameraContrast: float;
  42483. /**
  42484. * Gets the Color Grading 2D Lookup Texture.
  42485. */
  42486. /**
  42487. * Sets the Color Grading 2D Lookup Texture.
  42488. */
  42489. cameraColorGradingTexture: Nullable<BaseTexture>;
  42490. /**
  42491. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42492. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42493. * 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;
  42494. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42495. */
  42496. /**
  42497. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42498. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42499. * 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;
  42500. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42501. */
  42502. cameraColorCurves: Nullable<ColorCurves>;
  42503. /**
  42504. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  42505. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  42506. */
  42507. switchToBGR: boolean;
  42508. private _renderTargets;
  42509. private _reflectionControls;
  42510. private _white;
  42511. private _primaryShadowColor;
  42512. private _primaryHighlightColor;
  42513. /**
  42514. * Instantiates a Background Material in the given scene
  42515. * @param name The friendly name of the material
  42516. * @param scene The scene to add the material to
  42517. */
  42518. constructor(name: string, scene: Scene);
  42519. /**
  42520. * Gets a boolean indicating that current material needs to register RTT
  42521. */
  42522. readonly hasRenderTargetTextures: boolean;
  42523. /**
  42524. * The entire material has been created in order to prevent overdraw.
  42525. * @returns false
  42526. */
  42527. needAlphaTesting(): boolean;
  42528. /**
  42529. * The entire material has been created in order to prevent overdraw.
  42530. * @returns true if blending is enable
  42531. */
  42532. needAlphaBlending(): boolean;
  42533. /**
  42534. * Checks wether the material is ready to be rendered for a given mesh.
  42535. * @param mesh The mesh to render
  42536. * @param subMesh The submesh to check against
  42537. * @param useInstances Specify wether or not the material is used with instances
  42538. * @returns true if all the dependencies are ready (Textures, Effects...)
  42539. */
  42540. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42541. /**
  42542. * Compute the primary color according to the chosen perceptual color.
  42543. */
  42544. private _computePrimaryColorFromPerceptualColor;
  42545. /**
  42546. * Compute the highlights and shadow colors according to their chosen levels.
  42547. */
  42548. private _computePrimaryColors;
  42549. /**
  42550. * Build the uniform buffer used in the material.
  42551. */
  42552. buildUniformLayout(): void;
  42553. /**
  42554. * Unbind the material.
  42555. */
  42556. unbind(): void;
  42557. /**
  42558. * Bind only the world matrix to the material.
  42559. * @param world The world matrix to bind.
  42560. */
  42561. bindOnlyWorldMatrix(world: Matrix): void;
  42562. /**
  42563. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  42564. * @param world The world matrix to bind.
  42565. * @param subMesh The submesh to bind for.
  42566. */
  42567. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42568. /**
  42569. * Dispose the material.
  42570. * @param forceDisposeEffect Force disposal of the associated effect.
  42571. * @param forceDisposeTextures Force disposal of the associated textures.
  42572. */
  42573. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42574. /**
  42575. * Clones the material.
  42576. * @param name The cloned name.
  42577. * @returns The cloned material.
  42578. */
  42579. clone(name: string): BackgroundMaterial;
  42580. /**
  42581. * Serializes the current material to its JSON representation.
  42582. * @returns The JSON representation.
  42583. */
  42584. serialize(): any;
  42585. /**
  42586. * Gets the class name of the material
  42587. * @returns "BackgroundMaterial"
  42588. */
  42589. getClassName(): string;
  42590. /**
  42591. * Parse a JSON input to create back a background material.
  42592. * @param source The JSON data to parse
  42593. * @param scene The scene to create the parsed material in
  42594. * @param rootUrl The root url of the assets the material depends upon
  42595. * @returns the instantiated BackgroundMaterial.
  42596. */
  42597. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  42598. }
  42599. }
  42600. declare module BABYLON {
  42601. /**
  42602. * Represents the different options available during the creation of
  42603. * a Environment helper.
  42604. *
  42605. * This can control the default ground, skybox and image processing setup of your scene.
  42606. */
  42607. export interface IEnvironmentHelperOptions {
  42608. /**
  42609. * Specifies wether or not to create a ground.
  42610. * True by default.
  42611. */
  42612. createGround: boolean;
  42613. /**
  42614. * Specifies the ground size.
  42615. * 15 by default.
  42616. */
  42617. groundSize: number;
  42618. /**
  42619. * The texture used on the ground for the main color.
  42620. * Comes from the BabylonJS CDN by default.
  42621. *
  42622. * Remarks: Can be either a texture or a url.
  42623. */
  42624. groundTexture: string | BaseTexture;
  42625. /**
  42626. * The color mixed in the ground texture by default.
  42627. * BabylonJS clearColor by default.
  42628. */
  42629. groundColor: Color3;
  42630. /**
  42631. * Specifies the ground opacity.
  42632. * 1 by default.
  42633. */
  42634. groundOpacity: number;
  42635. /**
  42636. * Enables the ground to receive shadows.
  42637. * True by default.
  42638. */
  42639. enableGroundShadow: boolean;
  42640. /**
  42641. * Helps preventing the shadow to be fully black on the ground.
  42642. * 0.5 by default.
  42643. */
  42644. groundShadowLevel: number;
  42645. /**
  42646. * Creates a mirror texture attach to the ground.
  42647. * false by default.
  42648. */
  42649. enableGroundMirror: boolean;
  42650. /**
  42651. * Specifies the ground mirror size ratio.
  42652. * 0.3 by default as the default kernel is 64.
  42653. */
  42654. groundMirrorSizeRatio: number;
  42655. /**
  42656. * Specifies the ground mirror blur kernel size.
  42657. * 64 by default.
  42658. */
  42659. groundMirrorBlurKernel: number;
  42660. /**
  42661. * Specifies the ground mirror visibility amount.
  42662. * 1 by default
  42663. */
  42664. groundMirrorAmount: number;
  42665. /**
  42666. * Specifies the ground mirror reflectance weight.
  42667. * This uses the standard weight of the background material to setup the fresnel effect
  42668. * of the mirror.
  42669. * 1 by default.
  42670. */
  42671. groundMirrorFresnelWeight: number;
  42672. /**
  42673. * Specifies the ground mirror Falloff distance.
  42674. * This can helps reducing the size of the reflection.
  42675. * 0 by Default.
  42676. */
  42677. groundMirrorFallOffDistance: number;
  42678. /**
  42679. * Specifies the ground mirror texture type.
  42680. * Unsigned Int by Default.
  42681. */
  42682. groundMirrorTextureType: number;
  42683. /**
  42684. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  42685. * the shown objects.
  42686. */
  42687. groundYBias: number;
  42688. /**
  42689. * Specifies wether or not to create a skybox.
  42690. * True by default.
  42691. */
  42692. createSkybox: boolean;
  42693. /**
  42694. * Specifies the skybox size.
  42695. * 20 by default.
  42696. */
  42697. skyboxSize: number;
  42698. /**
  42699. * The texture used on the skybox for the main color.
  42700. * Comes from the BabylonJS CDN by default.
  42701. *
  42702. * Remarks: Can be either a texture or a url.
  42703. */
  42704. skyboxTexture: string | BaseTexture;
  42705. /**
  42706. * The color mixed in the skybox texture by default.
  42707. * BabylonJS clearColor by default.
  42708. */
  42709. skyboxColor: Color3;
  42710. /**
  42711. * The background rotation around the Y axis of the scene.
  42712. * This helps aligning the key lights of your scene with the background.
  42713. * 0 by default.
  42714. */
  42715. backgroundYRotation: number;
  42716. /**
  42717. * Compute automatically the size of the elements to best fit with the scene.
  42718. */
  42719. sizeAuto: boolean;
  42720. /**
  42721. * Default position of the rootMesh if autoSize is not true.
  42722. */
  42723. rootPosition: Vector3;
  42724. /**
  42725. * Sets up the image processing in the scene.
  42726. * true by default.
  42727. */
  42728. setupImageProcessing: boolean;
  42729. /**
  42730. * The texture used as your environment texture in the scene.
  42731. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  42732. *
  42733. * Remarks: Can be either a texture or a url.
  42734. */
  42735. environmentTexture: string | BaseTexture;
  42736. /**
  42737. * The value of the exposure to apply to the scene.
  42738. * 0.6 by default if setupImageProcessing is true.
  42739. */
  42740. cameraExposure: number;
  42741. /**
  42742. * The value of the contrast to apply to the scene.
  42743. * 1.6 by default if setupImageProcessing is true.
  42744. */
  42745. cameraContrast: number;
  42746. /**
  42747. * Specifies wether or not tonemapping should be enabled in the scene.
  42748. * true by default if setupImageProcessing is true.
  42749. */
  42750. toneMappingEnabled: boolean;
  42751. }
  42752. /**
  42753. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  42754. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  42755. * It also helps with the default setup of your imageProcessing configuration.
  42756. */
  42757. export class EnvironmentHelper {
  42758. /**
  42759. * Default ground texture URL.
  42760. */
  42761. private static _groundTextureCDNUrl;
  42762. /**
  42763. * Default skybox texture URL.
  42764. */
  42765. private static _skyboxTextureCDNUrl;
  42766. /**
  42767. * Default environment texture URL.
  42768. */
  42769. private static _environmentTextureCDNUrl;
  42770. /**
  42771. * Creates the default options for the helper.
  42772. */
  42773. private static _getDefaultOptions;
  42774. private _rootMesh;
  42775. /**
  42776. * Gets the root mesh created by the helper.
  42777. */
  42778. readonly rootMesh: Mesh;
  42779. private _skybox;
  42780. /**
  42781. * Gets the skybox created by the helper.
  42782. */
  42783. readonly skybox: Nullable<Mesh>;
  42784. private _skyboxTexture;
  42785. /**
  42786. * Gets the skybox texture created by the helper.
  42787. */
  42788. readonly skyboxTexture: Nullable<BaseTexture>;
  42789. private _skyboxMaterial;
  42790. /**
  42791. * Gets the skybox material created by the helper.
  42792. */
  42793. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  42794. private _ground;
  42795. /**
  42796. * Gets the ground mesh created by the helper.
  42797. */
  42798. readonly ground: Nullable<Mesh>;
  42799. private _groundTexture;
  42800. /**
  42801. * Gets the ground texture created by the helper.
  42802. */
  42803. readonly groundTexture: Nullable<BaseTexture>;
  42804. private _groundMirror;
  42805. /**
  42806. * Gets the ground mirror created by the helper.
  42807. */
  42808. readonly groundMirror: Nullable<MirrorTexture>;
  42809. /**
  42810. * Gets the ground mirror render list to helps pushing the meshes
  42811. * you wish in the ground reflection.
  42812. */
  42813. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  42814. private _groundMaterial;
  42815. /**
  42816. * Gets the ground material created by the helper.
  42817. */
  42818. readonly groundMaterial: Nullable<BackgroundMaterial>;
  42819. /**
  42820. * Stores the creation options.
  42821. */
  42822. private readonly _scene;
  42823. private _options;
  42824. /**
  42825. * This observable will be notified with any error during the creation of the environment,
  42826. * mainly texture creation errors.
  42827. */
  42828. onErrorObservable: Observable<{
  42829. message?: string;
  42830. exception?: any;
  42831. }>;
  42832. /**
  42833. * constructor
  42834. * @param options Defines the options we want to customize the helper
  42835. * @param scene The scene to add the material to
  42836. */
  42837. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  42838. /**
  42839. * Updates the background according to the new options
  42840. * @param options
  42841. */
  42842. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  42843. /**
  42844. * Sets the primary color of all the available elements.
  42845. * @param color the main color to affect to the ground and the background
  42846. */
  42847. setMainColor(color: Color3): void;
  42848. /**
  42849. * Setup the image processing according to the specified options.
  42850. */
  42851. private _setupImageProcessing;
  42852. /**
  42853. * Setup the environment texture according to the specified options.
  42854. */
  42855. private _setupEnvironmentTexture;
  42856. /**
  42857. * Setup the background according to the specified options.
  42858. */
  42859. private _setupBackground;
  42860. /**
  42861. * Get the scene sizes according to the setup.
  42862. */
  42863. private _getSceneSize;
  42864. /**
  42865. * Setup the ground according to the specified options.
  42866. */
  42867. private _setupGround;
  42868. /**
  42869. * Setup the ground material according to the specified options.
  42870. */
  42871. private _setupGroundMaterial;
  42872. /**
  42873. * Setup the ground diffuse texture according to the specified options.
  42874. */
  42875. private _setupGroundDiffuseTexture;
  42876. /**
  42877. * Setup the ground mirror texture according to the specified options.
  42878. */
  42879. private _setupGroundMirrorTexture;
  42880. /**
  42881. * Setup the ground to receive the mirror texture.
  42882. */
  42883. private _setupMirrorInGroundMaterial;
  42884. /**
  42885. * Setup the skybox according to the specified options.
  42886. */
  42887. private _setupSkybox;
  42888. /**
  42889. * Setup the skybox material according to the specified options.
  42890. */
  42891. private _setupSkyboxMaterial;
  42892. /**
  42893. * Setup the skybox reflection texture according to the specified options.
  42894. */
  42895. private _setupSkyboxReflectionTexture;
  42896. private _errorHandler;
  42897. /**
  42898. * Dispose all the elements created by the Helper.
  42899. */
  42900. dispose(): void;
  42901. }
  42902. }
  42903. declare module BABYLON {
  42904. /**
  42905. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  42906. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  42907. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  42908. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  42909. */
  42910. export class PhotoDome extends TransformNode {
  42911. private _useDirectMapping;
  42912. /**
  42913. * The texture being displayed on the sphere
  42914. */
  42915. protected _photoTexture: Texture;
  42916. /**
  42917. * Gets or sets the texture being displayed on the sphere
  42918. */
  42919. photoTexture: Texture;
  42920. /**
  42921. * Observable raised when an error occured while loading the 360 image
  42922. */
  42923. onLoadErrorObservable: Observable<string>;
  42924. /**
  42925. * The skybox material
  42926. */
  42927. protected _material: BackgroundMaterial;
  42928. /**
  42929. * The surface used for the skybox
  42930. */
  42931. protected _mesh: Mesh;
  42932. /**
  42933. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  42934. * Also see the options.resolution property.
  42935. */
  42936. fovMultiplier: number;
  42937. /**
  42938. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  42939. * @param name Element's name, child elements will append suffixes for their own names.
  42940. * @param urlsOfPhoto defines the url of the photo to display
  42941. * @param options defines an object containing optional or exposed sub element properties
  42942. * @param onError defines a callback called when an error occured while loading the texture
  42943. */
  42944. constructor(name: string, urlOfPhoto: string, options: {
  42945. resolution?: number;
  42946. size?: number;
  42947. useDirectMapping?: boolean;
  42948. faceForward?: boolean;
  42949. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  42950. /**
  42951. * Releases resources associated with this node.
  42952. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  42953. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  42954. */
  42955. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  42956. }
  42957. }
  42958. declare module BABYLON {
  42959. /** @hidden */
  42960. export var rgbdDecodePixelShader: {
  42961. name: string;
  42962. shader: string;
  42963. };
  42964. }
  42965. declare module BABYLON {
  42966. /**
  42967. * Class used to host texture specific utilities
  42968. */
  42969. export class BRDFTextureTools {
  42970. /**
  42971. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  42972. * @param texture the texture to expand.
  42973. */
  42974. private static _ExpandDefaultBRDFTexture;
  42975. /**
  42976. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  42977. * @param scene defines the hosting scene
  42978. * @returns the environment BRDF texture
  42979. */
  42980. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  42981. private static _environmentBRDFBase64Texture;
  42982. }
  42983. }
  42984. declare module BABYLON {
  42985. /**
  42986. * @hidden
  42987. */
  42988. export interface IMaterialClearCoatDefines {
  42989. CLEARCOAT: boolean;
  42990. CLEARCOAT_DEFAULTIOR: boolean;
  42991. CLEARCOAT_TEXTURE: boolean;
  42992. CLEARCOAT_TEXTUREDIRECTUV: number;
  42993. CLEARCOAT_BUMP: boolean;
  42994. CLEARCOAT_BUMPDIRECTUV: number;
  42995. CLEARCOAT_TINT: boolean;
  42996. CLEARCOAT_TINT_TEXTURE: boolean;
  42997. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  42998. /** @hidden */ areTexturesDirty: boolean;
  42999. }
  43000. /**
  43001. * Define the code related to the clear coat parameters of the pbr material.
  43002. */
  43003. export class PBRClearCoatConfiguration {
  43004. /**
  43005. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43006. * The default fits with a polyurethane material.
  43007. */
  43008. private static readonly _DefaultIndiceOfRefraction;
  43009. private _isEnabled;
  43010. /**
  43011. * Defines if the clear coat is enabled in the material.
  43012. */
  43013. isEnabled: boolean;
  43014. /**
  43015. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  43016. */
  43017. intensity: number;
  43018. /**
  43019. * Defines the clear coat layer roughness.
  43020. */
  43021. roughness: number;
  43022. private _indiceOfRefraction;
  43023. /**
  43024. * Defines the indice of refraction of the clear coat.
  43025. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43026. * The default fits with a polyurethane material.
  43027. * Changing the default value is more performance intensive.
  43028. */
  43029. indiceOfRefraction: number;
  43030. private _texture;
  43031. /**
  43032. * Stores the clear coat values in a texture.
  43033. */
  43034. texture: Nullable<BaseTexture>;
  43035. private _bumpTexture;
  43036. /**
  43037. * Define the clear coat specific bump texture.
  43038. */
  43039. bumpTexture: Nullable<BaseTexture>;
  43040. private _isTintEnabled;
  43041. /**
  43042. * Defines if the clear coat tint is enabled in the material.
  43043. */
  43044. isTintEnabled: boolean;
  43045. /**
  43046. * Defines the clear coat tint of the material.
  43047. * This is only use if tint is enabled
  43048. */
  43049. tintColor: Color3;
  43050. /**
  43051. * Defines the distance at which the tint color should be found in the
  43052. * clear coat media.
  43053. * This is only use if tint is enabled
  43054. */
  43055. tintColorAtDistance: number;
  43056. /**
  43057. * Defines the clear coat layer thickness.
  43058. * This is only use if tint is enabled
  43059. */
  43060. tintThickness: number;
  43061. private _tintTexture;
  43062. /**
  43063. * Stores the clear tint values in a texture.
  43064. * rgb is tint
  43065. * a is a thickness factor
  43066. */
  43067. tintTexture: Nullable<BaseTexture>;
  43068. /** @hidden */
  43069. private _internalMarkAllSubMeshesAsTexturesDirty;
  43070. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43071. /**
  43072. * Instantiate a new istance of clear coat configuration.
  43073. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43074. */
  43075. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43076. /**
  43077. * Gets wehter the submesh is ready to be used or not.
  43078. * @param defines the list of "defines" to update.
  43079. * @param scene defines the scene the material belongs to.
  43080. * @param engine defines the engine the material belongs to.
  43081. * @param disableBumpMap defines wether the material disables bump or not.
  43082. * @returns - boolean indicating that the submesh is ready or not.
  43083. */
  43084. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  43085. /**
  43086. * Checks to see if a texture is used in the material.
  43087. * @param defines the list of "defines" to update.
  43088. * @param scene defines the scene to the material belongs to.
  43089. */
  43090. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  43091. /**
  43092. * Binds the material data.
  43093. * @param uniformBuffer defines the Uniform buffer to fill in.
  43094. * @param scene defines the scene the material belongs to.
  43095. * @param engine defines the engine the material belongs to.
  43096. * @param disableBumpMap defines wether the material disables bump or not.
  43097. * @param isFrozen defines wether the material is frozen or not.
  43098. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  43099. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  43100. */
  43101. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  43102. /**
  43103. * Checks to see if a texture is used in the material.
  43104. * @param texture - Base texture to use.
  43105. * @returns - Boolean specifying if a texture is used in the material.
  43106. */
  43107. hasTexture(texture: BaseTexture): boolean;
  43108. /**
  43109. * Returns an array of the actively used textures.
  43110. * @param activeTextures Array of BaseTextures
  43111. */
  43112. getActiveTextures(activeTextures: BaseTexture[]): void;
  43113. /**
  43114. * Returns the animatable textures.
  43115. * @param animatables Array of animatable textures.
  43116. */
  43117. getAnimatables(animatables: IAnimatable[]): void;
  43118. /**
  43119. * Disposes the resources of the material.
  43120. * @param forceDisposeTextures - Forces the disposal of all textures.
  43121. */
  43122. dispose(forceDisposeTextures?: boolean): void;
  43123. /**
  43124. * Get the current class name of the texture useful for serialization or dynamic coding.
  43125. * @returns "PBRClearCoatConfiguration"
  43126. */
  43127. getClassName(): string;
  43128. /**
  43129. * Add fallbacks to the effect fallbacks list.
  43130. * @param defines defines the Base texture to use.
  43131. * @param fallbacks defines the current fallback list.
  43132. * @param currentRank defines the current fallback rank.
  43133. * @returns the new fallback rank.
  43134. */
  43135. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43136. /**
  43137. * Add the required uniforms to the current list.
  43138. * @param uniforms defines the current uniform list.
  43139. */
  43140. static AddUniforms(uniforms: string[]): void;
  43141. /**
  43142. * Add the required samplers to the current list.
  43143. * @param samplers defines the current sampler list.
  43144. */
  43145. static AddSamplers(samplers: string[]): void;
  43146. /**
  43147. * Add the required uniforms to the current buffer.
  43148. * @param uniformBuffer defines the current uniform buffer.
  43149. */
  43150. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43151. /**
  43152. * Makes a duplicate of the current configuration into another one.
  43153. * @param clearCoatConfiguration define the config where to copy the info
  43154. */
  43155. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  43156. /**
  43157. * Serializes this clear coat configuration.
  43158. * @returns - An object with the serialized config.
  43159. */
  43160. serialize(): any;
  43161. /**
  43162. * Parses a Clear Coat Configuration from a serialized object.
  43163. * @param source - Serialized object.
  43164. */
  43165. parse(source: any): void;
  43166. }
  43167. }
  43168. declare module BABYLON {
  43169. /**
  43170. * @hidden
  43171. */
  43172. export interface IMaterialAnisotropicDefines {
  43173. ANISOTROPIC: boolean;
  43174. ANISOTROPIC_TEXTURE: boolean;
  43175. ANISOTROPIC_TEXTUREDIRECTUV: number;
  43176. MAINUV1: boolean; areTexturesDirty: boolean; needUVs: boolean;
  43177. }
  43178. /**
  43179. * Define the code related to the anisotropic parameters of the pbr material.
  43180. */
  43181. export class PBRAnisotropicConfiguration {
  43182. private _isEnabled;
  43183. /**
  43184. * Defines if the anisotropy is enabled in the material.
  43185. */
  43186. isEnabled: boolean;
  43187. /**
  43188. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  43189. */
  43190. intensity: number;
  43191. /**
  43192. * Defines if the effect is along the tangents, bitangents or in between.
  43193. * By default, the effect is "strectching" the highlights along the tangents.
  43194. */
  43195. direction: Vector2;
  43196. private _texture;
  43197. /**
  43198. * Stores the anisotropy values in a texture.
  43199. * rg is direction (like normal from -1 to 1)
  43200. * b is a intensity
  43201. */
  43202. texture: Nullable<BaseTexture>;
  43203. /** @hidden */
  43204. private _internalMarkAllSubMeshesAsTexturesDirty;
  43205. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43206. /**
  43207. * Instantiate a new istance of anisotropy configuration.
  43208. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43209. */
  43210. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43211. /**
  43212. * Specifies that the submesh is ready to be used.
  43213. * @param defines the list of "defines" to update.
  43214. * @param scene defines the scene the material belongs to.
  43215. * @returns - boolean indicating that the submesh is ready or not.
  43216. */
  43217. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  43218. /**
  43219. * Checks to see if a texture is used in the material.
  43220. * @param defines the list of "defines" to update.
  43221. * @param mesh the mesh we are preparing the defines for.
  43222. * @param scene defines the scene the material belongs to.
  43223. */
  43224. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  43225. /**
  43226. * Binds the material data.
  43227. * @param uniformBuffer defines the Uniform buffer to fill in.
  43228. * @param scene defines the scene the material belongs to.
  43229. * @param isFrozen defines wether the material is frozen or not.
  43230. */
  43231. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  43232. /**
  43233. * Checks to see if a texture is used in the material.
  43234. * @param texture - Base texture to use.
  43235. * @returns - Boolean specifying if a texture is used in the material.
  43236. */
  43237. hasTexture(texture: BaseTexture): boolean;
  43238. /**
  43239. * Returns an array of the actively used textures.
  43240. * @param activeTextures Array of BaseTextures
  43241. */
  43242. getActiveTextures(activeTextures: BaseTexture[]): void;
  43243. /**
  43244. * Returns the animatable textures.
  43245. * @param animatables Array of animatable textures.
  43246. */
  43247. getAnimatables(animatables: IAnimatable[]): void;
  43248. /**
  43249. * Disposes the resources of the material.
  43250. * @param forceDisposeTextures - Forces the disposal of all textures.
  43251. */
  43252. dispose(forceDisposeTextures?: boolean): void;
  43253. /**
  43254. * Get the current class name of the texture useful for serialization or dynamic coding.
  43255. * @returns "PBRAnisotropicConfiguration"
  43256. */
  43257. getClassName(): string;
  43258. /**
  43259. * Add fallbacks to the effect fallbacks list.
  43260. * @param defines defines the Base texture to use.
  43261. * @param fallbacks defines the current fallback list.
  43262. * @param currentRank defines the current fallback rank.
  43263. * @returns the new fallback rank.
  43264. */
  43265. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43266. /**
  43267. * Add the required uniforms to the current list.
  43268. * @param uniforms defines the current uniform list.
  43269. */
  43270. static AddUniforms(uniforms: string[]): void;
  43271. /**
  43272. * Add the required uniforms to the current buffer.
  43273. * @param uniformBuffer defines the current uniform buffer.
  43274. */
  43275. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43276. /**
  43277. * Add the required samplers to the current list.
  43278. * @param samplers defines the current sampler list.
  43279. */
  43280. static AddSamplers(samplers: string[]): void;
  43281. /**
  43282. * Makes a duplicate of the current configuration into another one.
  43283. * @param anisotropicConfiguration define the config where to copy the info
  43284. */
  43285. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  43286. /**
  43287. * Serializes this anisotropy configuration.
  43288. * @returns - An object with the serialized config.
  43289. */
  43290. serialize(): any;
  43291. /**
  43292. * Parses a anisotropy Configuration from a serialized object.
  43293. * @param source - Serialized object.
  43294. */
  43295. parse(source: any): void;
  43296. }
  43297. }
  43298. declare module BABYLON {
  43299. /**
  43300. * @hidden
  43301. */
  43302. export interface IMaterialBRDFDefines {
  43303. BRDF_V_HEIGHT_CORRELATED: boolean;
  43304. MS_BRDF_ENERGY_CONSERVATION: boolean;
  43305. /** @hidden */ areMiscDirty: boolean;
  43306. }
  43307. /**
  43308. * Define the code related to the BRDF parameters of the pbr material.
  43309. */
  43310. export class PBRBRDFConfiguration {
  43311. /**
  43312. * Default value used for the energy conservation.
  43313. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  43314. */
  43315. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  43316. /**
  43317. * Default value used for the Smith Visibility Height Correlated mode.
  43318. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  43319. */
  43320. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  43321. private _useEnergyConservation;
  43322. /**
  43323. * Defines if the material uses energy conservation.
  43324. */
  43325. useEnergyConservation: boolean;
  43326. private _useSmithVisibilityHeightCorrelated;
  43327. /**
  43328. * LEGACY Mode set to false
  43329. * Defines if the material uses height smith correlated visibility term.
  43330. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  43331. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  43332. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  43333. * Not relying on height correlated will also disable energy conservation.
  43334. */
  43335. useSmithVisibilityHeightCorrelated: boolean;
  43336. /** @hidden */
  43337. private _internalMarkAllSubMeshesAsMiscDirty;
  43338. /** @hidden */ markAllSubMeshesAsMiscDirty(): void;
  43339. /**
  43340. * Instantiate a new istance of clear coat configuration.
  43341. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  43342. */
  43343. constructor(markAllSubMeshesAsMiscDirty: () => void);
  43344. /**
  43345. * Checks to see if a texture is used in the material.
  43346. * @param defines the list of "defines" to update.
  43347. */
  43348. prepareDefines(defines: IMaterialBRDFDefines): void;
  43349. /**
  43350. * Get the current class name of the texture useful for serialization or dynamic coding.
  43351. * @returns "PBRClearCoatConfiguration"
  43352. */
  43353. getClassName(): string;
  43354. /**
  43355. * Makes a duplicate of the current configuration into another one.
  43356. * @param brdfConfiguration define the config where to copy the info
  43357. */
  43358. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  43359. /**
  43360. * Serializes this BRDF configuration.
  43361. * @returns - An object with the serialized config.
  43362. */
  43363. serialize(): any;
  43364. /**
  43365. * Parses a BRDF Configuration from a serialized object.
  43366. * @param source - Serialized object.
  43367. */
  43368. parse(source: any): void;
  43369. }
  43370. }
  43371. declare module BABYLON {
  43372. /**
  43373. * @hidden
  43374. */
  43375. export interface IMaterialSheenDefines {
  43376. SHEEN: boolean;
  43377. SHEEN_TEXTURE: boolean;
  43378. SHEEN_TEXTUREDIRECTUV: number;
  43379. SHEEN_LINKWITHALBEDO: boolean;
  43380. /** @hidden */ areTexturesDirty: boolean;
  43381. }
  43382. /**
  43383. * Define the code related to the Sheen parameters of the pbr material.
  43384. */
  43385. export class PBRSheenConfiguration {
  43386. private _isEnabled;
  43387. /**
  43388. * Defines if the material uses sheen.
  43389. */
  43390. isEnabled: boolean;
  43391. private _linkSheenWithAlbedo;
  43392. /**
  43393. * Defines if the sheen is linked to the sheen color.
  43394. */
  43395. linkSheenWithAlbedo: boolean;
  43396. /**
  43397. * Defines the sheen intensity.
  43398. */
  43399. intensity: number;
  43400. /**
  43401. * Defines the sheen color.
  43402. */
  43403. color: Color3;
  43404. private _texture;
  43405. /**
  43406. * Stores the sheen tint values in a texture.
  43407. * rgb is tint
  43408. * a is a intensity
  43409. */
  43410. texture: Nullable<BaseTexture>;
  43411. /** @hidden */
  43412. private _internalMarkAllSubMeshesAsTexturesDirty;
  43413. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43414. /**
  43415. * Instantiate a new istance of clear coat configuration.
  43416. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43417. */
  43418. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43419. /**
  43420. * Specifies that the submesh is ready to be used.
  43421. * @param defines the list of "defines" to update.
  43422. * @param scene defines the scene the material belongs to.
  43423. * @returns - boolean indicating that the submesh is ready or not.
  43424. */
  43425. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  43426. /**
  43427. * Checks to see if a texture is used in the material.
  43428. * @param defines the list of "defines" to update.
  43429. * @param scene defines the scene the material belongs to.
  43430. */
  43431. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  43432. /**
  43433. * Binds the material data.
  43434. * @param uniformBuffer defines the Uniform buffer to fill in.
  43435. * @param scene defines the scene the material belongs to.
  43436. * @param isFrozen defines wether the material is frozen or not.
  43437. */
  43438. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  43439. /**
  43440. * Checks to see if a texture is used in the material.
  43441. * @param texture - Base texture to use.
  43442. * @returns - Boolean specifying if a texture is used in the material.
  43443. */
  43444. hasTexture(texture: BaseTexture): boolean;
  43445. /**
  43446. * Returns an array of the actively used textures.
  43447. * @param activeTextures Array of BaseTextures
  43448. */
  43449. getActiveTextures(activeTextures: BaseTexture[]): void;
  43450. /**
  43451. * Returns the animatable textures.
  43452. * @param animatables Array of animatable textures.
  43453. */
  43454. getAnimatables(animatables: IAnimatable[]): void;
  43455. /**
  43456. * Disposes the resources of the material.
  43457. * @param forceDisposeTextures - Forces the disposal of all textures.
  43458. */
  43459. dispose(forceDisposeTextures?: boolean): void;
  43460. /**
  43461. * Get the current class name of the texture useful for serialization or dynamic coding.
  43462. * @returns "PBRSheenConfiguration"
  43463. */
  43464. getClassName(): string;
  43465. /**
  43466. * Add fallbacks to the effect fallbacks list.
  43467. * @param defines defines the Base texture to use.
  43468. * @param fallbacks defines the current fallback list.
  43469. * @param currentRank defines the current fallback rank.
  43470. * @returns the new fallback rank.
  43471. */
  43472. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43473. /**
  43474. * Add the required uniforms to the current list.
  43475. * @param uniforms defines the current uniform list.
  43476. */
  43477. static AddUniforms(uniforms: string[]): void;
  43478. /**
  43479. * Add the required uniforms to the current buffer.
  43480. * @param uniformBuffer defines the current uniform buffer.
  43481. */
  43482. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43483. /**
  43484. * Add the required samplers to the current list.
  43485. * @param samplers defines the current sampler list.
  43486. */
  43487. static AddSamplers(samplers: string[]): void;
  43488. /**
  43489. * Makes a duplicate of the current configuration into another one.
  43490. * @param sheenConfiguration define the config where to copy the info
  43491. */
  43492. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  43493. /**
  43494. * Serializes this BRDF configuration.
  43495. * @returns - An object with the serialized config.
  43496. */
  43497. serialize(): any;
  43498. /**
  43499. * Parses a Sheen Configuration from a serialized object.
  43500. * @param source - Serialized object.
  43501. */
  43502. parse(source: any): void;
  43503. }
  43504. }
  43505. declare module BABYLON {
  43506. /**
  43507. * @hidden
  43508. */
  43509. export interface IMaterialSubSurfaceDefines {
  43510. SUBSURFACE: boolean;
  43511. SS_REFRACTION: boolean;
  43512. SS_TRANSLUCENCY: boolean;
  43513. SS_SCATERRING: boolean;
  43514. SS_THICKNESSANDMASK_TEXTURE: boolean;
  43515. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  43516. SS_REFRACTIONMAP_3D: boolean;
  43517. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  43518. SS_LODINREFRACTIONALPHA: boolean;
  43519. SS_GAMMAREFRACTION: boolean;
  43520. SS_RGBDREFRACTION: boolean;
  43521. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  43522. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  43523. /** @hidden */ areTexturesDirty: boolean;
  43524. }
  43525. /**
  43526. * Define the code related to the sub surface parameters of the pbr material.
  43527. */
  43528. export class PBRSubSurfaceConfiguration {
  43529. private _isRefractionEnabled;
  43530. /**
  43531. * Defines if the refraction is enabled in the material.
  43532. */
  43533. isRefractionEnabled: boolean;
  43534. private _isTranslucencyEnabled;
  43535. /**
  43536. * Defines if the translucency is enabled in the material.
  43537. */
  43538. isTranslucencyEnabled: boolean;
  43539. private _isScatteringEnabled;
  43540. /**
  43541. * Defines the refraction intensity of the material.
  43542. * The refraction when enabled replaces the Diffuse part of the material.
  43543. * The intensity helps transitionning between diffuse and refraction.
  43544. */
  43545. refractionIntensity: number;
  43546. /**
  43547. * Defines the translucency intensity of the material.
  43548. * When translucency has been enabled, this defines how much of the "translucency"
  43549. * is addded to the diffuse part of the material.
  43550. */
  43551. translucencyIntensity: number;
  43552. /**
  43553. * Defines the scattering intensity of the material.
  43554. * When scattering has been enabled, this defines how much of the "scattered light"
  43555. * is addded to the diffuse part of the material.
  43556. */
  43557. scatteringIntensity: number;
  43558. private _thicknessTexture;
  43559. /**
  43560. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  43561. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  43562. * 0 would mean minimumThickness
  43563. * 1 would mean maximumThickness
  43564. * The other channels might be use as a mask to vary the different effects intensity.
  43565. */
  43566. thicknessTexture: Nullable<BaseTexture>;
  43567. private _refractionTexture;
  43568. /**
  43569. * Defines the texture to use for refraction.
  43570. */
  43571. refractionTexture: Nullable<BaseTexture>;
  43572. private _indexOfRefraction;
  43573. /**
  43574. * Defines the indice of refraction used in the material.
  43575. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  43576. */
  43577. indexOfRefraction: number;
  43578. private _invertRefractionY;
  43579. /**
  43580. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  43581. */
  43582. invertRefractionY: boolean;
  43583. private _linkRefractionWithTransparency;
  43584. /**
  43585. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  43586. * Materials half opaque for instance using refraction could benefit from this control.
  43587. */
  43588. linkRefractionWithTransparency: boolean;
  43589. /**
  43590. * Defines the minimum thickness stored in the thickness map.
  43591. * If no thickness map is defined, this value will be used to simulate thickness.
  43592. */
  43593. minimumThickness: number;
  43594. /**
  43595. * Defines the maximum thickness stored in the thickness map.
  43596. */
  43597. maximumThickness: number;
  43598. /**
  43599. * Defines the volume tint of the material.
  43600. * This is used for both translucency and scattering.
  43601. */
  43602. tintColor: Color3;
  43603. /**
  43604. * Defines the distance at which the tint color should be found in the media.
  43605. * This is used for refraction only.
  43606. */
  43607. tintColorAtDistance: number;
  43608. /**
  43609. * Defines how far each channel transmit through the media.
  43610. * It is defined as a color to simplify it selection.
  43611. */
  43612. diffusionDistance: Color3;
  43613. private _useMaskFromThicknessTexture;
  43614. /**
  43615. * Stores the intensity of the different subsurface effects in the thickness texture.
  43616. * * the green channel is the translucency intensity.
  43617. * * the blue channel is the scattering intensity.
  43618. * * the alpha channel is the refraction intensity.
  43619. */
  43620. useMaskFromThicknessTexture: boolean;
  43621. /** @hidden */
  43622. private _internalMarkAllSubMeshesAsTexturesDirty;
  43623. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43624. /**
  43625. * Instantiate a new istance of sub surface configuration.
  43626. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43627. */
  43628. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43629. /**
  43630. * Gets wehter the submesh is ready to be used or not.
  43631. * @param defines the list of "defines" to update.
  43632. * @param scene defines the scene the material belongs to.
  43633. * @returns - boolean indicating that the submesh is ready or not.
  43634. */
  43635. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  43636. /**
  43637. * Checks to see if a texture is used in the material.
  43638. * @param defines the list of "defines" to update.
  43639. * @param scene defines the scene to the material belongs to.
  43640. */
  43641. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  43642. /**
  43643. * Binds the material data.
  43644. * @param uniformBuffer defines the Uniform buffer to fill in.
  43645. * @param scene defines the scene the material belongs to.
  43646. * @param engine defines the engine the material belongs to.
  43647. * @param isFrozen defines wether the material is frozen or not.
  43648. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  43649. */
  43650. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  43651. /**
  43652. * Unbinds the material from the mesh.
  43653. * @param activeEffect defines the effect that should be unbound from.
  43654. * @returns true if unbound, otherwise false
  43655. */
  43656. unbind(activeEffect: Effect): boolean;
  43657. /**
  43658. * Returns the texture used for refraction or null if none is used.
  43659. * @param scene defines the scene the material belongs to.
  43660. * @returns - Refraction texture if present. If no refraction texture and refraction
  43661. * is linked with transparency, returns environment texture. Otherwise, returns null.
  43662. */
  43663. private _getRefractionTexture;
  43664. /**
  43665. * Returns true if alpha blending should be disabled.
  43666. */
  43667. readonly disableAlphaBlending: boolean;
  43668. /**
  43669. * Fills the list of render target textures.
  43670. * @param renderTargets the list of render targets to update
  43671. */
  43672. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  43673. /**
  43674. * Checks to see if a texture is used in the material.
  43675. * @param texture - Base texture to use.
  43676. * @returns - Boolean specifying if a texture is used in the material.
  43677. */
  43678. hasTexture(texture: BaseTexture): boolean;
  43679. /**
  43680. * Gets a boolean indicating that current material needs to register RTT
  43681. * @returns true if this uses a render target otherwise false.
  43682. */
  43683. hasRenderTargetTextures(): boolean;
  43684. /**
  43685. * Returns an array of the actively used textures.
  43686. * @param activeTextures Array of BaseTextures
  43687. */
  43688. getActiveTextures(activeTextures: BaseTexture[]): void;
  43689. /**
  43690. * Returns the animatable textures.
  43691. * @param animatables Array of animatable textures.
  43692. */
  43693. getAnimatables(animatables: IAnimatable[]): void;
  43694. /**
  43695. * Disposes the resources of the material.
  43696. * @param forceDisposeTextures - Forces the disposal of all textures.
  43697. */
  43698. dispose(forceDisposeTextures?: boolean): void;
  43699. /**
  43700. * Get the current class name of the texture useful for serialization or dynamic coding.
  43701. * @returns "PBRSubSurfaceConfiguration"
  43702. */
  43703. getClassName(): string;
  43704. /**
  43705. * Add fallbacks to the effect fallbacks list.
  43706. * @param defines defines the Base texture to use.
  43707. * @param fallbacks defines the current fallback list.
  43708. * @param currentRank defines the current fallback rank.
  43709. * @returns the new fallback rank.
  43710. */
  43711. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43712. /**
  43713. * Add the required uniforms to the current list.
  43714. * @param uniforms defines the current uniform list.
  43715. */
  43716. static AddUniforms(uniforms: string[]): void;
  43717. /**
  43718. * Add the required samplers to the current list.
  43719. * @param samplers defines the current sampler list.
  43720. */
  43721. static AddSamplers(samplers: string[]): void;
  43722. /**
  43723. * Add the required uniforms to the current buffer.
  43724. * @param uniformBuffer defines the current uniform buffer.
  43725. */
  43726. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43727. /**
  43728. * Makes a duplicate of the current configuration into another one.
  43729. * @param configuration define the config where to copy the info
  43730. */
  43731. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  43732. /**
  43733. * Serializes this Sub Surface configuration.
  43734. * @returns - An object with the serialized config.
  43735. */
  43736. serialize(): any;
  43737. /**
  43738. * Parses a Sub Surface Configuration from a serialized object.
  43739. * @param source - Serialized object.
  43740. */
  43741. parse(source: any): void;
  43742. }
  43743. }
  43744. declare module BABYLON {
  43745. /** @hidden */
  43746. export var pbrFragmentDeclaration: {
  43747. name: string;
  43748. shader: string;
  43749. };
  43750. }
  43751. declare module BABYLON {
  43752. /** @hidden */
  43753. export var pbrUboDeclaration: {
  43754. name: string;
  43755. shader: string;
  43756. };
  43757. }
  43758. declare module BABYLON {
  43759. /** @hidden */
  43760. export var pbrFragmentExtraDeclaration: {
  43761. name: string;
  43762. shader: string;
  43763. };
  43764. }
  43765. declare module BABYLON {
  43766. /** @hidden */
  43767. export var pbrFragmentSamplersDeclaration: {
  43768. name: string;
  43769. shader: string;
  43770. };
  43771. }
  43772. declare module BABYLON {
  43773. /** @hidden */
  43774. export var pbrHelperFunctions: {
  43775. name: string;
  43776. shader: string;
  43777. };
  43778. }
  43779. declare module BABYLON {
  43780. /** @hidden */
  43781. export var harmonicsFunctions: {
  43782. name: string;
  43783. shader: string;
  43784. };
  43785. }
  43786. declare module BABYLON {
  43787. /** @hidden */
  43788. export var pbrDirectLightingSetupFunctions: {
  43789. name: string;
  43790. shader: string;
  43791. };
  43792. }
  43793. declare module BABYLON {
  43794. /** @hidden */
  43795. export var pbrDirectLightingFalloffFunctions: {
  43796. name: string;
  43797. shader: string;
  43798. };
  43799. }
  43800. declare module BABYLON {
  43801. /** @hidden */
  43802. export var pbrBRDFFunctions: {
  43803. name: string;
  43804. shader: string;
  43805. };
  43806. }
  43807. declare module BABYLON {
  43808. /** @hidden */
  43809. export var pbrDirectLightingFunctions: {
  43810. name: string;
  43811. shader: string;
  43812. };
  43813. }
  43814. declare module BABYLON {
  43815. /** @hidden */
  43816. export var pbrIBLFunctions: {
  43817. name: string;
  43818. shader: string;
  43819. };
  43820. }
  43821. declare module BABYLON {
  43822. /** @hidden */
  43823. export var pbrDebug: {
  43824. name: string;
  43825. shader: string;
  43826. };
  43827. }
  43828. declare module BABYLON {
  43829. /** @hidden */
  43830. export var pbrPixelShader: {
  43831. name: string;
  43832. shader: string;
  43833. };
  43834. }
  43835. declare module BABYLON {
  43836. /** @hidden */
  43837. export var pbrVertexDeclaration: {
  43838. name: string;
  43839. shader: string;
  43840. };
  43841. }
  43842. declare module BABYLON {
  43843. /** @hidden */
  43844. export var pbrVertexShader: {
  43845. name: string;
  43846. shader: string;
  43847. };
  43848. }
  43849. declare module BABYLON {
  43850. /**
  43851. * Manages the defines for the PBR Material.
  43852. * @hidden
  43853. */
  43854. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  43855. PBR: boolean;
  43856. MAINUV1: boolean;
  43857. MAINUV2: boolean;
  43858. UV1: boolean;
  43859. UV2: boolean;
  43860. ALBEDO: boolean;
  43861. ALBEDODIRECTUV: number;
  43862. VERTEXCOLOR: boolean;
  43863. AMBIENT: boolean;
  43864. AMBIENTDIRECTUV: number;
  43865. AMBIENTINGRAYSCALE: boolean;
  43866. OPACITY: boolean;
  43867. VERTEXALPHA: boolean;
  43868. OPACITYDIRECTUV: number;
  43869. OPACITYRGB: boolean;
  43870. ALPHATEST: boolean;
  43871. DEPTHPREPASS: boolean;
  43872. ALPHABLEND: boolean;
  43873. ALPHAFROMALBEDO: boolean;
  43874. ALPHATESTVALUE: string;
  43875. SPECULAROVERALPHA: boolean;
  43876. RADIANCEOVERALPHA: boolean;
  43877. ALPHAFRESNEL: boolean;
  43878. LINEARALPHAFRESNEL: boolean;
  43879. PREMULTIPLYALPHA: boolean;
  43880. EMISSIVE: boolean;
  43881. EMISSIVEDIRECTUV: number;
  43882. REFLECTIVITY: boolean;
  43883. REFLECTIVITYDIRECTUV: number;
  43884. SPECULARTERM: boolean;
  43885. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  43886. MICROSURFACEAUTOMATIC: boolean;
  43887. LODBASEDMICROSFURACE: boolean;
  43888. MICROSURFACEMAP: boolean;
  43889. MICROSURFACEMAPDIRECTUV: number;
  43890. METALLICWORKFLOW: boolean;
  43891. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  43892. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  43893. METALLNESSSTOREINMETALMAPBLUE: boolean;
  43894. AOSTOREINMETALMAPRED: boolean;
  43895. ENVIRONMENTBRDF: boolean;
  43896. ENVIRONMENTBRDF_RGBD: boolean;
  43897. NORMAL: boolean;
  43898. TANGENT: boolean;
  43899. BUMP: boolean;
  43900. BUMPDIRECTUV: number;
  43901. OBJECTSPACE_NORMALMAP: boolean;
  43902. PARALLAX: boolean;
  43903. PARALLAXOCCLUSION: boolean;
  43904. NORMALXYSCALE: boolean;
  43905. LIGHTMAP: boolean;
  43906. LIGHTMAPDIRECTUV: number;
  43907. USELIGHTMAPASSHADOWMAP: boolean;
  43908. GAMMALIGHTMAP: boolean;
  43909. REFLECTION: boolean;
  43910. REFLECTIONMAP_3D: boolean;
  43911. REFLECTIONMAP_SPHERICAL: boolean;
  43912. REFLECTIONMAP_PLANAR: boolean;
  43913. REFLECTIONMAP_CUBIC: boolean;
  43914. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  43915. REFLECTIONMAP_PROJECTION: boolean;
  43916. REFLECTIONMAP_SKYBOX: boolean;
  43917. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  43918. REFLECTIONMAP_EXPLICIT: boolean;
  43919. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  43920. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  43921. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  43922. INVERTCUBICMAP: boolean;
  43923. USESPHERICALFROMREFLECTIONMAP: boolean;
  43924. USESPHERICALINVERTEX: boolean;
  43925. REFLECTIONMAP_OPPOSITEZ: boolean;
  43926. LODINREFLECTIONALPHA: boolean;
  43927. GAMMAREFLECTION: boolean;
  43928. RGBDREFLECTION: boolean;
  43929. RADIANCEOCCLUSION: boolean;
  43930. HORIZONOCCLUSION: boolean;
  43931. INSTANCES: boolean;
  43932. NUM_BONE_INFLUENCERS: number;
  43933. BonesPerMesh: number;
  43934. BONETEXTURE: boolean;
  43935. NONUNIFORMSCALING: boolean;
  43936. MORPHTARGETS: boolean;
  43937. MORPHTARGETS_NORMAL: boolean;
  43938. MORPHTARGETS_TANGENT: boolean;
  43939. NUM_MORPH_INFLUENCERS: number;
  43940. IMAGEPROCESSING: boolean;
  43941. VIGNETTE: boolean;
  43942. VIGNETTEBLENDMODEMULTIPLY: boolean;
  43943. VIGNETTEBLENDMODEOPAQUE: boolean;
  43944. TONEMAPPING: boolean;
  43945. TONEMAPPING_ACES: boolean;
  43946. CONTRAST: boolean;
  43947. COLORCURVES: boolean;
  43948. COLORGRADING: boolean;
  43949. COLORGRADING3D: boolean;
  43950. SAMPLER3DGREENDEPTH: boolean;
  43951. SAMPLER3DBGRMAP: boolean;
  43952. IMAGEPROCESSINGPOSTPROCESS: boolean;
  43953. EXPOSURE: boolean;
  43954. MULTIVIEW: boolean;
  43955. USEPHYSICALLIGHTFALLOFF: boolean;
  43956. USEGLTFLIGHTFALLOFF: boolean;
  43957. TWOSIDEDLIGHTING: boolean;
  43958. SHADOWFLOAT: boolean;
  43959. CLIPPLANE: boolean;
  43960. CLIPPLANE2: boolean;
  43961. CLIPPLANE3: boolean;
  43962. CLIPPLANE4: boolean;
  43963. POINTSIZE: boolean;
  43964. FOG: boolean;
  43965. LOGARITHMICDEPTH: boolean;
  43966. FORCENORMALFORWARD: boolean;
  43967. SPECULARAA: boolean;
  43968. CLEARCOAT: boolean;
  43969. CLEARCOAT_DEFAULTIOR: boolean;
  43970. CLEARCOAT_TEXTURE: boolean;
  43971. CLEARCOAT_TEXTUREDIRECTUV: number;
  43972. CLEARCOAT_BUMP: boolean;
  43973. CLEARCOAT_BUMPDIRECTUV: number;
  43974. CLEARCOAT_TINT: boolean;
  43975. CLEARCOAT_TINT_TEXTURE: boolean;
  43976. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  43977. ANISOTROPIC: boolean;
  43978. ANISOTROPIC_TEXTURE: boolean;
  43979. ANISOTROPIC_TEXTUREDIRECTUV: number;
  43980. BRDF_V_HEIGHT_CORRELATED: boolean;
  43981. MS_BRDF_ENERGY_CONSERVATION: boolean;
  43982. SHEEN: boolean;
  43983. SHEEN_TEXTURE: boolean;
  43984. SHEEN_TEXTUREDIRECTUV: number;
  43985. SHEEN_LINKWITHALBEDO: boolean;
  43986. SUBSURFACE: boolean;
  43987. SS_REFRACTION: boolean;
  43988. SS_TRANSLUCENCY: boolean;
  43989. SS_SCATERRING: boolean;
  43990. SS_THICKNESSANDMASK_TEXTURE: boolean;
  43991. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  43992. SS_REFRACTIONMAP_3D: boolean;
  43993. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  43994. SS_LODINREFRACTIONALPHA: boolean;
  43995. SS_GAMMAREFRACTION: boolean;
  43996. SS_RGBDREFRACTION: boolean;
  43997. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  43998. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  43999. UNLIT: boolean;
  44000. DEBUGMODE: number;
  44001. /**
  44002. * Initializes the PBR Material defines.
  44003. */
  44004. constructor();
  44005. /**
  44006. * Resets the PBR Material defines.
  44007. */
  44008. reset(): void;
  44009. }
  44010. /**
  44011. * The Physically based material base class of BJS.
  44012. *
  44013. * This offers the main features of a standard PBR material.
  44014. * For more information, please refer to the documentation :
  44015. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44016. */
  44017. export abstract class PBRBaseMaterial extends PushMaterial {
  44018. /**
  44019. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44020. */
  44021. static readonly PBRMATERIAL_OPAQUE: number;
  44022. /**
  44023. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44024. */
  44025. static readonly PBRMATERIAL_ALPHATEST: number;
  44026. /**
  44027. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44028. */
  44029. static readonly PBRMATERIAL_ALPHABLEND: number;
  44030. /**
  44031. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44032. * They are also discarded below the alpha cutoff threshold to improve performances.
  44033. */
  44034. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44035. /**
  44036. * Defines the default value of how much AO map is occluding the analytical lights
  44037. * (point spot...).
  44038. */
  44039. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44040. /**
  44041. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44042. */
  44043. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44044. /**
  44045. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44046. * to enhance interoperability with other engines.
  44047. */
  44048. static readonly LIGHTFALLOFF_GLTF: number;
  44049. /**
  44050. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44051. * to enhance interoperability with other materials.
  44052. */
  44053. static readonly LIGHTFALLOFF_STANDARD: number;
  44054. /**
  44055. * Intensity of the direct lights e.g. the four lights available in your scene.
  44056. * This impacts both the direct diffuse and specular highlights.
  44057. */
  44058. protected _directIntensity: number;
  44059. /**
  44060. * Intensity of the emissive part of the material.
  44061. * This helps controlling the emissive effect without modifying the emissive color.
  44062. */
  44063. protected _emissiveIntensity: number;
  44064. /**
  44065. * Intensity of the environment e.g. how much the environment will light the object
  44066. * either through harmonics for rough material or through the refelction for shiny ones.
  44067. */
  44068. protected _environmentIntensity: number;
  44069. /**
  44070. * This is a special control allowing the reduction of the specular highlights coming from the
  44071. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44072. */
  44073. protected _specularIntensity: number;
  44074. /**
  44075. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44076. */
  44077. private _lightingInfos;
  44078. /**
  44079. * Debug Control allowing disabling the bump map on this material.
  44080. */
  44081. protected _disableBumpMap: boolean;
  44082. /**
  44083. * AKA Diffuse Texture in standard nomenclature.
  44084. */
  44085. protected _albedoTexture: BaseTexture;
  44086. /**
  44087. * AKA Occlusion Texture in other nomenclature.
  44088. */
  44089. protected _ambientTexture: BaseTexture;
  44090. /**
  44091. * AKA Occlusion Texture Intensity in other nomenclature.
  44092. */
  44093. protected _ambientTextureStrength: number;
  44094. /**
  44095. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44096. * 1 means it completely occludes it
  44097. * 0 mean it has no impact
  44098. */
  44099. protected _ambientTextureImpactOnAnalyticalLights: number;
  44100. /**
  44101. * Stores the alpha values in a texture.
  44102. */
  44103. protected _opacityTexture: BaseTexture;
  44104. /**
  44105. * Stores the reflection values in a texture.
  44106. */
  44107. protected _reflectionTexture: BaseTexture;
  44108. /**
  44109. * Stores the emissive values in a texture.
  44110. */
  44111. protected _emissiveTexture: BaseTexture;
  44112. /**
  44113. * AKA Specular texture in other nomenclature.
  44114. */
  44115. protected _reflectivityTexture: BaseTexture;
  44116. /**
  44117. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44118. */
  44119. protected _metallicTexture: BaseTexture;
  44120. /**
  44121. * Specifies the metallic scalar of the metallic/roughness workflow.
  44122. * Can also be used to scale the metalness values of the metallic texture.
  44123. */
  44124. protected _metallic: Nullable<number>;
  44125. /**
  44126. * Specifies the roughness scalar of the metallic/roughness workflow.
  44127. * Can also be used to scale the roughness values of the metallic texture.
  44128. */
  44129. protected _roughness: Nullable<number>;
  44130. /**
  44131. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44132. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44133. */
  44134. protected _microSurfaceTexture: BaseTexture;
  44135. /**
  44136. * Stores surface normal data used to displace a mesh in a texture.
  44137. */
  44138. protected _bumpTexture: BaseTexture;
  44139. /**
  44140. * Stores the pre-calculated light information of a mesh in a texture.
  44141. */
  44142. protected _lightmapTexture: BaseTexture;
  44143. /**
  44144. * The color of a material in ambient lighting.
  44145. */
  44146. protected _ambientColor: Color3;
  44147. /**
  44148. * AKA Diffuse Color in other nomenclature.
  44149. */
  44150. protected _albedoColor: Color3;
  44151. /**
  44152. * AKA Specular Color in other nomenclature.
  44153. */
  44154. protected _reflectivityColor: Color3;
  44155. /**
  44156. * The color applied when light is reflected from a material.
  44157. */
  44158. protected _reflectionColor: Color3;
  44159. /**
  44160. * The color applied when light is emitted from a material.
  44161. */
  44162. protected _emissiveColor: Color3;
  44163. /**
  44164. * AKA Glossiness in other nomenclature.
  44165. */
  44166. protected _microSurface: number;
  44167. /**
  44168. * Specifies that the material will use the light map as a show map.
  44169. */
  44170. protected _useLightmapAsShadowmap: boolean;
  44171. /**
  44172. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44173. * makes the reflect vector face the model (under horizon).
  44174. */
  44175. protected _useHorizonOcclusion: boolean;
  44176. /**
  44177. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44178. * too much the area relying on ambient texture to define their ambient occlusion.
  44179. */
  44180. protected _useRadianceOcclusion: boolean;
  44181. /**
  44182. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44183. */
  44184. protected _useAlphaFromAlbedoTexture: boolean;
  44185. /**
  44186. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44187. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44188. */
  44189. protected _useSpecularOverAlpha: boolean;
  44190. /**
  44191. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44192. */
  44193. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44194. /**
  44195. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44196. */
  44197. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44198. /**
  44199. * Specifies if the metallic texture contains the roughness information in its green channel.
  44200. */
  44201. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44202. /**
  44203. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44204. */
  44205. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44206. /**
  44207. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44208. */
  44209. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44210. /**
  44211. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44212. */
  44213. protected _useAmbientInGrayScale: boolean;
  44214. /**
  44215. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44216. * The material will try to infer what glossiness each pixel should be.
  44217. */
  44218. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44219. /**
  44220. * Defines the falloff type used in this material.
  44221. * It by default is Physical.
  44222. */
  44223. protected _lightFalloff: number;
  44224. /**
  44225. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44226. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44227. */
  44228. protected _useRadianceOverAlpha: boolean;
  44229. /**
  44230. * Allows using an object space normal map (instead of tangent space).
  44231. */
  44232. protected _useObjectSpaceNormalMap: boolean;
  44233. /**
  44234. * Allows using the bump map in parallax mode.
  44235. */
  44236. protected _useParallax: boolean;
  44237. /**
  44238. * Allows using the bump map in parallax occlusion mode.
  44239. */
  44240. protected _useParallaxOcclusion: boolean;
  44241. /**
  44242. * Controls the scale bias of the parallax mode.
  44243. */
  44244. protected _parallaxScaleBias: number;
  44245. /**
  44246. * If sets to true, disables all the lights affecting the material.
  44247. */
  44248. protected _disableLighting: boolean;
  44249. /**
  44250. * Number of Simultaneous lights allowed on the material.
  44251. */
  44252. protected _maxSimultaneousLights: number;
  44253. /**
  44254. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44255. */
  44256. protected _invertNormalMapX: boolean;
  44257. /**
  44258. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44259. */
  44260. protected _invertNormalMapY: boolean;
  44261. /**
  44262. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44263. */
  44264. protected _twoSidedLighting: boolean;
  44265. /**
  44266. * Defines the alpha limits in alpha test mode.
  44267. */
  44268. protected _alphaCutOff: number;
  44269. /**
  44270. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44271. */
  44272. protected _forceAlphaTest: boolean;
  44273. /**
  44274. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44275. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44276. */
  44277. protected _useAlphaFresnel: boolean;
  44278. /**
  44279. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44280. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44281. */
  44282. protected _useLinearAlphaFresnel: boolean;
  44283. /**
  44284. * The transparency mode of the material.
  44285. */
  44286. protected _transparencyMode: Nullable<number>;
  44287. /**
  44288. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44289. * from cos thetav and roughness:
  44290. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44291. */
  44292. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44293. /**
  44294. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44295. */
  44296. protected _forceIrradianceInFragment: boolean;
  44297. /**
  44298. * Force normal to face away from face.
  44299. */
  44300. protected _forceNormalForward: boolean;
  44301. /**
  44302. * Enables specular anti aliasing in the PBR shader.
  44303. * It will both interacts on the Geometry for analytical and IBL lighting.
  44304. * It also prefilter the roughness map based on the bump values.
  44305. */
  44306. protected _enableSpecularAntiAliasing: boolean;
  44307. /**
  44308. * Default configuration related to image processing available in the PBR Material.
  44309. */
  44310. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44311. /**
  44312. * Keep track of the image processing observer to allow dispose and replace.
  44313. */
  44314. private _imageProcessingObserver;
  44315. /**
  44316. * Attaches a new image processing configuration to the PBR Material.
  44317. * @param configuration
  44318. */
  44319. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44320. /**
  44321. * Stores the available render targets.
  44322. */
  44323. private _renderTargets;
  44324. /**
  44325. * Sets the global ambient color for the material used in lighting calculations.
  44326. */
  44327. private _globalAmbientColor;
  44328. /**
  44329. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44330. */
  44331. private _useLogarithmicDepth;
  44332. /**
  44333. * If set to true, no lighting calculations will be applied.
  44334. */
  44335. private _unlit;
  44336. private _debugMode;
  44337. /**
  44338. * @hidden
  44339. * This is reserved for the inspector.
  44340. * Defines the material debug mode.
  44341. * It helps seeing only some components of the material while troubleshooting.
  44342. */
  44343. debugMode: number;
  44344. /**
  44345. * @hidden
  44346. * This is reserved for the inspector.
  44347. * Specify from where on screen the debug mode should start.
  44348. * The value goes from -1 (full screen) to 1 (not visible)
  44349. * It helps with side by side comparison against the final render
  44350. * This defaults to -1
  44351. */
  44352. private debugLimit;
  44353. /**
  44354. * @hidden
  44355. * This is reserved for the inspector.
  44356. * As the default viewing range might not be enough (if the ambient is really small for instance)
  44357. * You can use the factor to better multiply the final value.
  44358. */
  44359. private debugFactor;
  44360. /**
  44361. * Defines the clear coat layer parameters for the material.
  44362. */
  44363. readonly clearCoat: PBRClearCoatConfiguration;
  44364. /**
  44365. * Defines the anisotropic parameters for the material.
  44366. */
  44367. readonly anisotropy: PBRAnisotropicConfiguration;
  44368. /**
  44369. * Defines the BRDF parameters for the material.
  44370. */
  44371. readonly brdf: PBRBRDFConfiguration;
  44372. /**
  44373. * Defines the Sheen parameters for the material.
  44374. */
  44375. readonly sheen: PBRSheenConfiguration;
  44376. /**
  44377. * Defines the SubSurface parameters for the material.
  44378. */
  44379. readonly subSurface: PBRSubSurfaceConfiguration;
  44380. /**
  44381. * Custom callback helping to override the default shader used in the material.
  44382. */
  44383. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  44384. /**
  44385. * Instantiates a new PBRMaterial instance.
  44386. *
  44387. * @param name The material name
  44388. * @param scene The scene the material will be use in.
  44389. */
  44390. constructor(name: string, scene: Scene);
  44391. /**
  44392. * Gets a boolean indicating that current material needs to register RTT
  44393. */
  44394. readonly hasRenderTargetTextures: boolean;
  44395. /**
  44396. * Gets the name of the material class.
  44397. */
  44398. getClassName(): string;
  44399. /**
  44400. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44401. */
  44402. /**
  44403. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44404. */
  44405. useLogarithmicDepth: boolean;
  44406. /**
  44407. * Gets the current transparency mode.
  44408. */
  44409. /**
  44410. * Sets the transparency mode of the material.
  44411. *
  44412. * | Value | Type | Description |
  44413. * | ----- | ----------------------------------- | ----------- |
  44414. * | 0 | OPAQUE | |
  44415. * | 1 | ALPHATEST | |
  44416. * | 2 | ALPHABLEND | |
  44417. * | 3 | ALPHATESTANDBLEND | |
  44418. *
  44419. */
  44420. transparencyMode: Nullable<number>;
  44421. /**
  44422. * Returns true if alpha blending should be disabled.
  44423. */
  44424. private readonly _disableAlphaBlending;
  44425. /**
  44426. * Specifies whether or not this material should be rendered in alpha blend mode.
  44427. */
  44428. needAlphaBlending(): boolean;
  44429. /**
  44430. * Specifies if the mesh will require alpha blending.
  44431. * @param mesh - BJS mesh.
  44432. */
  44433. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  44434. /**
  44435. * Specifies whether or not this material should be rendered in alpha test mode.
  44436. */
  44437. needAlphaTesting(): boolean;
  44438. /**
  44439. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  44440. */
  44441. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  44442. /**
  44443. * Gets the texture used for the alpha test.
  44444. */
  44445. getAlphaTestTexture(): BaseTexture;
  44446. /**
  44447. * Specifies that the submesh is ready to be used.
  44448. * @param mesh - BJS mesh.
  44449. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  44450. * @param useInstances - Specifies that instances should be used.
  44451. * @returns - boolean indicating that the submesh is ready or not.
  44452. */
  44453. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44454. /**
  44455. * Specifies if the material uses metallic roughness workflow.
  44456. * @returns boolean specifiying if the material uses metallic roughness workflow.
  44457. */
  44458. isMetallicWorkflow(): boolean;
  44459. private _prepareEffect;
  44460. private _prepareDefines;
  44461. /**
  44462. * Force shader compilation
  44463. */
  44464. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  44465. clipPlane: boolean;
  44466. }>): void;
  44467. /**
  44468. * Initializes the uniform buffer layout for the shader.
  44469. */
  44470. buildUniformLayout(): void;
  44471. /**
  44472. * Unbinds the material from the mesh
  44473. */
  44474. unbind(): void;
  44475. /**
  44476. * Binds the submesh data.
  44477. * @param world - The world matrix.
  44478. * @param mesh - The BJS mesh.
  44479. * @param subMesh - A submesh of the BJS mesh.
  44480. */
  44481. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44482. /**
  44483. * Returns the animatable textures.
  44484. * @returns - Array of animatable textures.
  44485. */
  44486. getAnimatables(): IAnimatable[];
  44487. /**
  44488. * Returns the texture used for reflections.
  44489. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  44490. */
  44491. private _getReflectionTexture;
  44492. /**
  44493. * Returns an array of the actively used textures.
  44494. * @returns - Array of BaseTextures
  44495. */
  44496. getActiveTextures(): BaseTexture[];
  44497. /**
  44498. * Checks to see if a texture is used in the material.
  44499. * @param texture - Base texture to use.
  44500. * @returns - Boolean specifying if a texture is used in the material.
  44501. */
  44502. hasTexture(texture: BaseTexture): boolean;
  44503. /**
  44504. * Disposes the resources of the material.
  44505. * @param forceDisposeEffect - Forces the disposal of effects.
  44506. * @param forceDisposeTextures - Forces the disposal of all textures.
  44507. */
  44508. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44509. }
  44510. }
  44511. declare module BABYLON {
  44512. /**
  44513. * The Physically based material of BJS.
  44514. *
  44515. * This offers the main features of a standard PBR material.
  44516. * For more information, please refer to the documentation :
  44517. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44518. */
  44519. export class PBRMaterial extends PBRBaseMaterial {
  44520. /**
  44521. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44522. */
  44523. static readonly PBRMATERIAL_OPAQUE: number;
  44524. /**
  44525. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44526. */
  44527. static readonly PBRMATERIAL_ALPHATEST: number;
  44528. /**
  44529. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44530. */
  44531. static readonly PBRMATERIAL_ALPHABLEND: number;
  44532. /**
  44533. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44534. * They are also discarded below the alpha cutoff threshold to improve performances.
  44535. */
  44536. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44537. /**
  44538. * Defines the default value of how much AO map is occluding the analytical lights
  44539. * (point spot...).
  44540. */
  44541. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44542. /**
  44543. * Intensity of the direct lights e.g. the four lights available in your scene.
  44544. * This impacts both the direct diffuse and specular highlights.
  44545. */
  44546. directIntensity: number;
  44547. /**
  44548. * Intensity of the emissive part of the material.
  44549. * This helps controlling the emissive effect without modifying the emissive color.
  44550. */
  44551. emissiveIntensity: number;
  44552. /**
  44553. * Intensity of the environment e.g. how much the environment will light the object
  44554. * either through harmonics for rough material or through the refelction for shiny ones.
  44555. */
  44556. environmentIntensity: number;
  44557. /**
  44558. * This is a special control allowing the reduction of the specular highlights coming from the
  44559. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44560. */
  44561. specularIntensity: number;
  44562. /**
  44563. * Debug Control allowing disabling the bump map on this material.
  44564. */
  44565. disableBumpMap: boolean;
  44566. /**
  44567. * AKA Diffuse Texture in standard nomenclature.
  44568. */
  44569. albedoTexture: BaseTexture;
  44570. /**
  44571. * AKA Occlusion Texture in other nomenclature.
  44572. */
  44573. ambientTexture: BaseTexture;
  44574. /**
  44575. * AKA Occlusion Texture Intensity in other nomenclature.
  44576. */
  44577. ambientTextureStrength: number;
  44578. /**
  44579. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44580. * 1 means it completely occludes it
  44581. * 0 mean it has no impact
  44582. */
  44583. ambientTextureImpactOnAnalyticalLights: number;
  44584. /**
  44585. * Stores the alpha values in a texture.
  44586. */
  44587. opacityTexture: BaseTexture;
  44588. /**
  44589. * Stores the reflection values in a texture.
  44590. */
  44591. reflectionTexture: Nullable<BaseTexture>;
  44592. /**
  44593. * Stores the emissive values in a texture.
  44594. */
  44595. emissiveTexture: BaseTexture;
  44596. /**
  44597. * AKA Specular texture in other nomenclature.
  44598. */
  44599. reflectivityTexture: BaseTexture;
  44600. /**
  44601. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44602. */
  44603. metallicTexture: BaseTexture;
  44604. /**
  44605. * Specifies the metallic scalar of the metallic/roughness workflow.
  44606. * Can also be used to scale the metalness values of the metallic texture.
  44607. */
  44608. metallic: Nullable<number>;
  44609. /**
  44610. * Specifies the roughness scalar of the metallic/roughness workflow.
  44611. * Can also be used to scale the roughness values of the metallic texture.
  44612. */
  44613. roughness: Nullable<number>;
  44614. /**
  44615. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44616. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44617. */
  44618. microSurfaceTexture: BaseTexture;
  44619. /**
  44620. * Stores surface normal data used to displace a mesh in a texture.
  44621. */
  44622. bumpTexture: BaseTexture;
  44623. /**
  44624. * Stores the pre-calculated light information of a mesh in a texture.
  44625. */
  44626. lightmapTexture: BaseTexture;
  44627. /**
  44628. * Stores the refracted light information in a texture.
  44629. */
  44630. refractionTexture: Nullable<BaseTexture>;
  44631. /**
  44632. * The color of a material in ambient lighting.
  44633. */
  44634. ambientColor: Color3;
  44635. /**
  44636. * AKA Diffuse Color in other nomenclature.
  44637. */
  44638. albedoColor: Color3;
  44639. /**
  44640. * AKA Specular Color in other nomenclature.
  44641. */
  44642. reflectivityColor: Color3;
  44643. /**
  44644. * The color reflected from the material.
  44645. */
  44646. reflectionColor: Color3;
  44647. /**
  44648. * The color emitted from the material.
  44649. */
  44650. emissiveColor: Color3;
  44651. /**
  44652. * AKA Glossiness in other nomenclature.
  44653. */
  44654. microSurface: number;
  44655. /**
  44656. * source material index of refraction (IOR)' / 'destination material IOR.
  44657. */
  44658. indexOfRefraction: number;
  44659. /**
  44660. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44661. */
  44662. invertRefractionY: boolean;
  44663. /**
  44664. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44665. * Materials half opaque for instance using refraction could benefit from this control.
  44666. */
  44667. linkRefractionWithTransparency: boolean;
  44668. /**
  44669. * If true, the light map contains occlusion information instead of lighting info.
  44670. */
  44671. useLightmapAsShadowmap: boolean;
  44672. /**
  44673. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44674. */
  44675. useAlphaFromAlbedoTexture: boolean;
  44676. /**
  44677. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44678. */
  44679. forceAlphaTest: boolean;
  44680. /**
  44681. * Defines the alpha limits in alpha test mode.
  44682. */
  44683. alphaCutOff: number;
  44684. /**
  44685. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  44686. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44687. */
  44688. useSpecularOverAlpha: boolean;
  44689. /**
  44690. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44691. */
  44692. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44693. /**
  44694. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44695. */
  44696. useRoughnessFromMetallicTextureAlpha: boolean;
  44697. /**
  44698. * Specifies if the metallic texture contains the roughness information in its green channel.
  44699. */
  44700. useRoughnessFromMetallicTextureGreen: boolean;
  44701. /**
  44702. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44703. */
  44704. useMetallnessFromMetallicTextureBlue: boolean;
  44705. /**
  44706. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44707. */
  44708. useAmbientOcclusionFromMetallicTextureRed: boolean;
  44709. /**
  44710. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44711. */
  44712. useAmbientInGrayScale: boolean;
  44713. /**
  44714. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44715. * The material will try to infer what glossiness each pixel should be.
  44716. */
  44717. useAutoMicroSurfaceFromReflectivityMap: boolean;
  44718. /**
  44719. * BJS is using an harcoded light falloff based on a manually sets up range.
  44720. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44721. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44722. */
  44723. /**
  44724. * BJS is using an harcoded light falloff based on a manually sets up range.
  44725. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44726. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44727. */
  44728. usePhysicalLightFalloff: boolean;
  44729. /**
  44730. * In order to support the falloff compatibility with gltf, a special mode has been added
  44731. * to reproduce the gltf light falloff.
  44732. */
  44733. /**
  44734. * In order to support the falloff compatibility with gltf, a special mode has been added
  44735. * to reproduce the gltf light falloff.
  44736. */
  44737. useGLTFLightFalloff: boolean;
  44738. /**
  44739. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44740. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44741. */
  44742. useRadianceOverAlpha: boolean;
  44743. /**
  44744. * Allows using an object space normal map (instead of tangent space).
  44745. */
  44746. useObjectSpaceNormalMap: boolean;
  44747. /**
  44748. * Allows using the bump map in parallax mode.
  44749. */
  44750. useParallax: boolean;
  44751. /**
  44752. * Allows using the bump map in parallax occlusion mode.
  44753. */
  44754. useParallaxOcclusion: boolean;
  44755. /**
  44756. * Controls the scale bias of the parallax mode.
  44757. */
  44758. parallaxScaleBias: number;
  44759. /**
  44760. * If sets to true, disables all the lights affecting the material.
  44761. */
  44762. disableLighting: boolean;
  44763. /**
  44764. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44765. */
  44766. forceIrradianceInFragment: boolean;
  44767. /**
  44768. * Number of Simultaneous lights allowed on the material.
  44769. */
  44770. maxSimultaneousLights: number;
  44771. /**
  44772. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  44773. */
  44774. invertNormalMapX: boolean;
  44775. /**
  44776. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  44777. */
  44778. invertNormalMapY: boolean;
  44779. /**
  44780. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44781. */
  44782. twoSidedLighting: boolean;
  44783. /**
  44784. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44785. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44786. */
  44787. useAlphaFresnel: boolean;
  44788. /**
  44789. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44790. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44791. */
  44792. useLinearAlphaFresnel: boolean;
  44793. /**
  44794. * Let user defines the brdf lookup texture used for IBL.
  44795. * A default 8bit version is embedded but you could point at :
  44796. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  44797. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  44798. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44799. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  44800. */
  44801. environmentBRDFTexture: Nullable<BaseTexture>;
  44802. /**
  44803. * Force normal to face away from face.
  44804. */
  44805. forceNormalForward: boolean;
  44806. /**
  44807. * Enables specular anti aliasing in the PBR shader.
  44808. * It will both interacts on the Geometry for analytical and IBL lighting.
  44809. * It also prefilter the roughness map based on the bump values.
  44810. */
  44811. enableSpecularAntiAliasing: boolean;
  44812. /**
  44813. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44814. * makes the reflect vector face the model (under horizon).
  44815. */
  44816. useHorizonOcclusion: boolean;
  44817. /**
  44818. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44819. * too much the area relying on ambient texture to define their ambient occlusion.
  44820. */
  44821. useRadianceOcclusion: boolean;
  44822. /**
  44823. * If set to true, no lighting calculations will be applied.
  44824. */
  44825. unlit: boolean;
  44826. /**
  44827. * Gets the image processing configuration used either in this material.
  44828. */
  44829. /**
  44830. * Sets the Default image processing configuration used either in the this material.
  44831. *
  44832. * If sets to null, the scene one is in use.
  44833. */
  44834. imageProcessingConfiguration: ImageProcessingConfiguration;
  44835. /**
  44836. * Gets wether the color curves effect is enabled.
  44837. */
  44838. /**
  44839. * Sets wether the color curves effect is enabled.
  44840. */
  44841. cameraColorCurvesEnabled: boolean;
  44842. /**
  44843. * Gets wether the color grading effect is enabled.
  44844. */
  44845. /**
  44846. * Gets wether the color grading effect is enabled.
  44847. */
  44848. cameraColorGradingEnabled: boolean;
  44849. /**
  44850. * Gets wether tonemapping is enabled or not.
  44851. */
  44852. /**
  44853. * Sets wether tonemapping is enabled or not
  44854. */
  44855. cameraToneMappingEnabled: boolean;
  44856. /**
  44857. * The camera exposure used on this material.
  44858. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44859. * This corresponds to a photographic exposure.
  44860. */
  44861. /**
  44862. * The camera exposure used on this material.
  44863. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44864. * This corresponds to a photographic exposure.
  44865. */
  44866. cameraExposure: number;
  44867. /**
  44868. * Gets The camera contrast used on this material.
  44869. */
  44870. /**
  44871. * Sets The camera contrast used on this material.
  44872. */
  44873. cameraContrast: number;
  44874. /**
  44875. * Gets the Color Grading 2D Lookup Texture.
  44876. */
  44877. /**
  44878. * Sets the Color Grading 2D Lookup Texture.
  44879. */
  44880. cameraColorGradingTexture: Nullable<BaseTexture>;
  44881. /**
  44882. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44883. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44884. * 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;
  44885. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44886. */
  44887. /**
  44888. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44889. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44890. * 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;
  44891. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44892. */
  44893. cameraColorCurves: Nullable<ColorCurves>;
  44894. /**
  44895. * Instantiates a new PBRMaterial instance.
  44896. *
  44897. * @param name The material name
  44898. * @param scene The scene the material will be use in.
  44899. */
  44900. constructor(name: string, scene: Scene);
  44901. /**
  44902. * Returns the name of this material class.
  44903. */
  44904. getClassName(): string;
  44905. /**
  44906. * Makes a duplicate of the current material.
  44907. * @param name - name to use for the new material.
  44908. */
  44909. clone(name: string): PBRMaterial;
  44910. /**
  44911. * Serializes this PBR Material.
  44912. * @returns - An object with the serialized material.
  44913. */
  44914. serialize(): any;
  44915. /**
  44916. * Parses a PBR Material from a serialized object.
  44917. * @param source - Serialized object.
  44918. * @param scene - BJS scene instance.
  44919. * @param rootUrl - url for the scene object
  44920. * @returns - PBRMaterial
  44921. */
  44922. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  44923. }
  44924. }
  44925. declare module BABYLON {
  44926. /**
  44927. * Direct draw surface info
  44928. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  44929. */
  44930. export interface DDSInfo {
  44931. /**
  44932. * Width of the texture
  44933. */
  44934. width: number;
  44935. /**
  44936. * Width of the texture
  44937. */
  44938. height: number;
  44939. /**
  44940. * Number of Mipmaps for the texture
  44941. * @see https://en.wikipedia.org/wiki/Mipmap
  44942. */
  44943. mipmapCount: number;
  44944. /**
  44945. * If the textures format is a known fourCC format
  44946. * @see https://www.fourcc.org/
  44947. */
  44948. isFourCC: boolean;
  44949. /**
  44950. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  44951. */
  44952. isRGB: boolean;
  44953. /**
  44954. * If the texture is a lumincance format
  44955. */
  44956. isLuminance: boolean;
  44957. /**
  44958. * If this is a cube texture
  44959. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  44960. */
  44961. isCube: boolean;
  44962. /**
  44963. * If the texture is a compressed format eg. FOURCC_DXT1
  44964. */
  44965. isCompressed: boolean;
  44966. /**
  44967. * The dxgiFormat of the texture
  44968. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  44969. */
  44970. dxgiFormat: number;
  44971. /**
  44972. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  44973. */
  44974. textureType: number;
  44975. /**
  44976. * Sphericle polynomial created for the dds texture
  44977. */
  44978. sphericalPolynomial?: SphericalPolynomial;
  44979. }
  44980. /**
  44981. * Class used to provide DDS decompression tools
  44982. */
  44983. export class DDSTools {
  44984. /**
  44985. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  44986. */
  44987. static StoreLODInAlphaChannel: boolean;
  44988. /**
  44989. * Gets DDS information from an array buffer
  44990. * @param arrayBuffer defines the array buffer to read data from
  44991. * @returns the DDS information
  44992. */
  44993. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  44994. private static _FloatView;
  44995. private static _Int32View;
  44996. private static _ToHalfFloat;
  44997. private static _FromHalfFloat;
  44998. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  44999. private static _GetHalfFloatRGBAArrayBuffer;
  45000. private static _GetFloatRGBAArrayBuffer;
  45001. private static _GetFloatAsUIntRGBAArrayBuffer;
  45002. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  45003. private static _GetRGBAArrayBuffer;
  45004. private static _ExtractLongWordOrder;
  45005. private static _GetRGBArrayBuffer;
  45006. private static _GetLuminanceArrayBuffer;
  45007. /**
  45008. * Uploads DDS Levels to a Babylon Texture
  45009. * @hidden
  45010. */
  45011. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  45012. }
  45013. interface Engine {
  45014. /**
  45015. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  45016. * @param rootUrl defines the url where the file to load is located
  45017. * @param scene defines the current scene
  45018. * @param lodScale defines scale to apply to the mip map selection
  45019. * @param lodOffset defines offset to apply to the mip map selection
  45020. * @param onLoad defines an optional callback raised when the texture is loaded
  45021. * @param onError defines an optional callback raised if there is an issue to load the texture
  45022. * @param format defines the format of the data
  45023. * @param forcedExtension defines the extension to use to pick the right loader
  45024. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  45025. * @returns the cube texture as an InternalTexture
  45026. */
  45027. 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;
  45028. }
  45029. }
  45030. declare module BABYLON {
  45031. /**
  45032. * Implementation of the DDS Texture Loader.
  45033. * @hidden
  45034. */
  45035. export class _DDSTextureLoader implements IInternalTextureLoader {
  45036. /**
  45037. * Defines wether the loader supports cascade loading the different faces.
  45038. */
  45039. readonly supportCascades: boolean;
  45040. /**
  45041. * This returns if the loader support the current file information.
  45042. * @param extension defines the file extension of the file being loaded
  45043. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45044. * @param fallback defines the fallback internal texture if any
  45045. * @param isBase64 defines whether the texture is encoded as a base64
  45046. * @param isBuffer defines whether the texture data are stored as a buffer
  45047. * @returns true if the loader can load the specified file
  45048. */
  45049. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45050. /**
  45051. * Transform the url before loading if required.
  45052. * @param rootUrl the url of the texture
  45053. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45054. * @returns the transformed texture
  45055. */
  45056. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45057. /**
  45058. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45059. * @param rootUrl the url of the texture
  45060. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45061. * @returns the fallback texture
  45062. */
  45063. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45064. /**
  45065. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45066. * @param data contains the texture data
  45067. * @param texture defines the BabylonJS internal texture
  45068. * @param createPolynomials will be true if polynomials have been requested
  45069. * @param onLoad defines the callback to trigger once the texture is ready
  45070. * @param onError defines the callback to trigger in case of error
  45071. */
  45072. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45073. /**
  45074. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45075. * @param data contains the texture data
  45076. * @param texture defines the BabylonJS internal texture
  45077. * @param callback defines the method to call once ready to upload
  45078. */
  45079. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45080. }
  45081. }
  45082. declare module BABYLON {
  45083. /** @hidden */
  45084. export var rgbdEncodePixelShader: {
  45085. name: string;
  45086. shader: string;
  45087. };
  45088. }
  45089. declare module BABYLON {
  45090. /**
  45091. * Raw texture data and descriptor sufficient for WebGL texture upload
  45092. */
  45093. export interface EnvironmentTextureInfo {
  45094. /**
  45095. * Version of the environment map
  45096. */
  45097. version: number;
  45098. /**
  45099. * Width of image
  45100. */
  45101. width: number;
  45102. /**
  45103. * Irradiance information stored in the file.
  45104. */
  45105. irradiance: any;
  45106. /**
  45107. * Specular information stored in the file.
  45108. */
  45109. specular: any;
  45110. }
  45111. /**
  45112. * Sets of helpers addressing the serialization and deserialization of environment texture
  45113. * stored in a BabylonJS env file.
  45114. * Those files are usually stored as .env files.
  45115. */
  45116. export class EnvironmentTextureTools {
  45117. /**
  45118. * Magic number identifying the env file.
  45119. */
  45120. private static _MagicBytes;
  45121. /**
  45122. * Gets the environment info from an env file.
  45123. * @param data The array buffer containing the .env bytes.
  45124. * @returns the environment file info (the json header) if successfully parsed.
  45125. */
  45126. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45127. /**
  45128. * Creates an environment texture from a loaded cube texture.
  45129. * @param texture defines the cube texture to convert in env file
  45130. * @return a promise containing the environment data if succesfull.
  45131. */
  45132. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45133. /**
  45134. * Creates a JSON representation of the spherical data.
  45135. * @param texture defines the texture containing the polynomials
  45136. * @return the JSON representation of the spherical info
  45137. */
  45138. private static _CreateEnvTextureIrradiance;
  45139. /**
  45140. * Uploads the texture info contained in the env file to the GPU.
  45141. * @param texture defines the internal texture to upload to
  45142. * @param arrayBuffer defines the buffer cotaining the data to load
  45143. * @param info defines the texture info retrieved through the GetEnvInfo method
  45144. * @returns a promise
  45145. */
  45146. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45147. /**
  45148. * Uploads the levels of image data to the GPU.
  45149. * @param texture defines the internal texture to upload to
  45150. * @param imageData defines the array buffer views of image data [mipmap][face]
  45151. * @returns a promise
  45152. */
  45153. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45154. /**
  45155. * Uploads spherical polynomials information to the texture.
  45156. * @param texture defines the texture we are trying to upload the information to
  45157. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45158. */
  45159. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45160. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45161. }
  45162. }
  45163. declare module BABYLON {
  45164. /**
  45165. * Implementation of the ENV Texture Loader.
  45166. * @hidden
  45167. */
  45168. export class _ENVTextureLoader implements IInternalTextureLoader {
  45169. /**
  45170. * Defines wether the loader supports cascade loading the different faces.
  45171. */
  45172. readonly supportCascades: boolean;
  45173. /**
  45174. * This returns if the loader support the current file information.
  45175. * @param extension defines the file extension of the file being loaded
  45176. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45177. * @param fallback defines the fallback internal texture if any
  45178. * @param isBase64 defines whether the texture is encoded as a base64
  45179. * @param isBuffer defines whether the texture data are stored as a buffer
  45180. * @returns true if the loader can load the specified file
  45181. */
  45182. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45183. /**
  45184. * Transform the url before loading if required.
  45185. * @param rootUrl the url of the texture
  45186. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45187. * @returns the transformed texture
  45188. */
  45189. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45190. /**
  45191. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45192. * @param rootUrl the url of the texture
  45193. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45194. * @returns the fallback texture
  45195. */
  45196. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45197. /**
  45198. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45199. * @param data contains the texture data
  45200. * @param texture defines the BabylonJS internal texture
  45201. * @param createPolynomials will be true if polynomials have been requested
  45202. * @param onLoad defines the callback to trigger once the texture is ready
  45203. * @param onError defines the callback to trigger in case of error
  45204. */
  45205. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45206. /**
  45207. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45208. * @param data contains the texture data
  45209. * @param texture defines the BabylonJS internal texture
  45210. * @param callback defines the method to call once ready to upload
  45211. */
  45212. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45213. }
  45214. }
  45215. declare module BABYLON {
  45216. /**
  45217. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  45218. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  45219. */
  45220. export class KhronosTextureContainer {
  45221. /** contents of the KTX container file */
  45222. arrayBuffer: any;
  45223. private static HEADER_LEN;
  45224. private static COMPRESSED_2D;
  45225. private static COMPRESSED_3D;
  45226. private static TEX_2D;
  45227. private static TEX_3D;
  45228. /**
  45229. * Gets the openGL type
  45230. */
  45231. glType: number;
  45232. /**
  45233. * Gets the openGL type size
  45234. */
  45235. glTypeSize: number;
  45236. /**
  45237. * Gets the openGL format
  45238. */
  45239. glFormat: number;
  45240. /**
  45241. * Gets the openGL internal format
  45242. */
  45243. glInternalFormat: number;
  45244. /**
  45245. * Gets the base internal format
  45246. */
  45247. glBaseInternalFormat: number;
  45248. /**
  45249. * Gets image width in pixel
  45250. */
  45251. pixelWidth: number;
  45252. /**
  45253. * Gets image height in pixel
  45254. */
  45255. pixelHeight: number;
  45256. /**
  45257. * Gets image depth in pixels
  45258. */
  45259. pixelDepth: number;
  45260. /**
  45261. * Gets the number of array elements
  45262. */
  45263. numberOfArrayElements: number;
  45264. /**
  45265. * Gets the number of faces
  45266. */
  45267. numberOfFaces: number;
  45268. /**
  45269. * Gets the number of mipmap levels
  45270. */
  45271. numberOfMipmapLevels: number;
  45272. /**
  45273. * Gets the bytes of key value data
  45274. */
  45275. bytesOfKeyValueData: number;
  45276. /**
  45277. * Gets the load type
  45278. */
  45279. loadType: number;
  45280. /**
  45281. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  45282. */
  45283. isInvalid: boolean;
  45284. /**
  45285. * Creates a new KhronosTextureContainer
  45286. * @param arrayBuffer contents of the KTX container file
  45287. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  45288. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  45289. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  45290. */
  45291. constructor(
  45292. /** contents of the KTX container file */
  45293. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  45294. /**
  45295. * Uploads KTX content to a Babylon Texture.
  45296. * It is assumed that the texture has already been created & is currently bound
  45297. * @hidden
  45298. */
  45299. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  45300. private _upload2DCompressedLevels;
  45301. }
  45302. }
  45303. declare module BABYLON {
  45304. /**
  45305. * Implementation of the KTX Texture Loader.
  45306. * @hidden
  45307. */
  45308. export class _KTXTextureLoader implements IInternalTextureLoader {
  45309. /**
  45310. * Defines wether the loader supports cascade loading the different faces.
  45311. */
  45312. readonly supportCascades: boolean;
  45313. /**
  45314. * This returns if the loader support the current file information.
  45315. * @param extension defines the file extension of the file being loaded
  45316. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45317. * @param fallback defines the fallback internal texture if any
  45318. * @param isBase64 defines whether the texture is encoded as a base64
  45319. * @param isBuffer defines whether the texture data are stored as a buffer
  45320. * @returns true if the loader can load the specified file
  45321. */
  45322. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45323. /**
  45324. * Transform the url before loading if required.
  45325. * @param rootUrl the url of the texture
  45326. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45327. * @returns the transformed texture
  45328. */
  45329. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45330. /**
  45331. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45332. * @param rootUrl the url of the texture
  45333. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45334. * @returns the fallback texture
  45335. */
  45336. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45337. /**
  45338. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45339. * @param data contains the texture data
  45340. * @param texture defines the BabylonJS internal texture
  45341. * @param createPolynomials will be true if polynomials have been requested
  45342. * @param onLoad defines the callback to trigger once the texture is ready
  45343. * @param onError defines the callback to trigger in case of error
  45344. */
  45345. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45346. /**
  45347. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45348. * @param data contains the texture data
  45349. * @param texture defines the BabylonJS internal texture
  45350. * @param callback defines the method to call once ready to upload
  45351. */
  45352. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  45353. }
  45354. }
  45355. declare module BABYLON {
  45356. /** @hidden */
  45357. export var _forceSceneHelpersToBundle: boolean;
  45358. interface Scene {
  45359. /**
  45360. * Creates a default light for the scene.
  45361. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  45362. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  45363. */
  45364. createDefaultLight(replace?: boolean): void;
  45365. /**
  45366. * Creates a default camera for the scene.
  45367. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  45368. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45369. * @param replace has default false, when true replaces the active camera in the scene
  45370. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  45371. */
  45372. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45373. /**
  45374. * Creates a default camera and a default light.
  45375. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  45376. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45377. * @param replace has the default false, when true replaces the active camera/light in the scene
  45378. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  45379. */
  45380. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45381. /**
  45382. * Creates a new sky box
  45383. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  45384. * @param environmentTexture defines the texture to use as environment texture
  45385. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  45386. * @param scale defines the overall scale of the skybox
  45387. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  45388. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  45389. * @returns a new mesh holding the sky box
  45390. */
  45391. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  45392. /**
  45393. * Creates a new environment
  45394. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  45395. * @param options defines the options you can use to configure the environment
  45396. * @returns the new EnvironmentHelper
  45397. */
  45398. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  45399. /**
  45400. * Creates a new VREXperienceHelper
  45401. * @see http://doc.babylonjs.com/how_to/webvr_helper
  45402. * @param webVROptions defines the options used to create the new VREXperienceHelper
  45403. * @returns a new VREXperienceHelper
  45404. */
  45405. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  45406. /**
  45407. * Creates a new XREXperienceHelper
  45408. * @see http://doc.babylonjs.com/how_to/webxr
  45409. * @returns a promise for a new XREXperienceHelper
  45410. */
  45411. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  45412. }
  45413. }
  45414. declare module BABYLON {
  45415. /**
  45416. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  45417. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  45418. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  45419. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45420. */
  45421. export class VideoDome extends TransformNode {
  45422. /**
  45423. * Define the video source as a Monoscopic panoramic 360 video.
  45424. */
  45425. static readonly MODE_MONOSCOPIC: number;
  45426. /**
  45427. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45428. */
  45429. static readonly MODE_TOPBOTTOM: number;
  45430. /**
  45431. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45432. */
  45433. static readonly MODE_SIDEBYSIDE: number;
  45434. private _useDirectMapping;
  45435. /**
  45436. * The video texture being displayed on the sphere
  45437. */
  45438. protected _videoTexture: VideoTexture;
  45439. /**
  45440. * Gets the video texture being displayed on the sphere
  45441. */
  45442. readonly videoTexture: VideoTexture;
  45443. /**
  45444. * The skybox material
  45445. */
  45446. protected _material: BackgroundMaterial;
  45447. /**
  45448. * The surface used for the skybox
  45449. */
  45450. protected _mesh: Mesh;
  45451. /**
  45452. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45453. * Also see the options.resolution property.
  45454. */
  45455. fovMultiplier: number;
  45456. private _videoMode;
  45457. /**
  45458. * Gets or set the current video mode for the video. It can be:
  45459. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  45460. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45461. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45462. */
  45463. videoMode: number;
  45464. /**
  45465. * Oberserver used in Stereoscopic VR Mode.
  45466. */
  45467. private _onBeforeCameraRenderObserver;
  45468. /**
  45469. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  45470. * @param name Element's name, child elements will append suffixes for their own names.
  45471. * @param urlsOrVideo defines the url(s) or the video element to use
  45472. * @param options An object containing optional or exposed sub element properties
  45473. */
  45474. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  45475. resolution?: number;
  45476. clickToPlay?: boolean;
  45477. autoPlay?: boolean;
  45478. loop?: boolean;
  45479. size?: number;
  45480. poster?: string;
  45481. faceForward?: boolean;
  45482. useDirectMapping?: boolean;
  45483. }, scene: Scene);
  45484. private _changeVideoMode;
  45485. /**
  45486. * Releases resources associated with this node.
  45487. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45488. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45489. */
  45490. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45491. }
  45492. }
  45493. declare module BABYLON {
  45494. /**
  45495. * This class can be used to get instrumentation data from a Babylon engine
  45496. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45497. */
  45498. export class EngineInstrumentation implements IDisposable {
  45499. /**
  45500. * Define the instrumented engine.
  45501. */
  45502. engine: Engine;
  45503. private _captureGPUFrameTime;
  45504. private _gpuFrameTimeToken;
  45505. private _gpuFrameTime;
  45506. private _captureShaderCompilationTime;
  45507. private _shaderCompilationTime;
  45508. private _onBeginFrameObserver;
  45509. private _onEndFrameObserver;
  45510. private _onBeforeShaderCompilationObserver;
  45511. private _onAfterShaderCompilationObserver;
  45512. /**
  45513. * Gets the perf counter used for GPU frame time
  45514. */
  45515. readonly gpuFrameTimeCounter: PerfCounter;
  45516. /**
  45517. * Gets the GPU frame time capture status
  45518. */
  45519. /**
  45520. * Enable or disable the GPU frame time capture
  45521. */
  45522. captureGPUFrameTime: boolean;
  45523. /**
  45524. * Gets the perf counter used for shader compilation time
  45525. */
  45526. readonly shaderCompilationTimeCounter: PerfCounter;
  45527. /**
  45528. * Gets the shader compilation time capture status
  45529. */
  45530. /**
  45531. * Enable or disable the shader compilation time capture
  45532. */
  45533. captureShaderCompilationTime: boolean;
  45534. /**
  45535. * Instantiates a new engine instrumentation.
  45536. * This class can be used to get instrumentation data from a Babylon engine
  45537. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45538. * @param engine Defines the engine to instrument
  45539. */
  45540. constructor(
  45541. /**
  45542. * Define the instrumented engine.
  45543. */
  45544. engine: Engine);
  45545. /**
  45546. * Dispose and release associated resources.
  45547. */
  45548. dispose(): void;
  45549. }
  45550. }
  45551. declare module BABYLON {
  45552. /**
  45553. * This class can be used to get instrumentation data from a Babylon engine
  45554. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45555. */
  45556. export class SceneInstrumentation implements IDisposable {
  45557. /**
  45558. * Defines the scene to instrument
  45559. */
  45560. scene: Scene;
  45561. private _captureActiveMeshesEvaluationTime;
  45562. private _activeMeshesEvaluationTime;
  45563. private _captureRenderTargetsRenderTime;
  45564. private _renderTargetsRenderTime;
  45565. private _captureFrameTime;
  45566. private _frameTime;
  45567. private _captureRenderTime;
  45568. private _renderTime;
  45569. private _captureInterFrameTime;
  45570. private _interFrameTime;
  45571. private _captureParticlesRenderTime;
  45572. private _particlesRenderTime;
  45573. private _captureSpritesRenderTime;
  45574. private _spritesRenderTime;
  45575. private _capturePhysicsTime;
  45576. private _physicsTime;
  45577. private _captureAnimationsTime;
  45578. private _animationsTime;
  45579. private _captureCameraRenderTime;
  45580. private _cameraRenderTime;
  45581. private _onBeforeActiveMeshesEvaluationObserver;
  45582. private _onAfterActiveMeshesEvaluationObserver;
  45583. private _onBeforeRenderTargetsRenderObserver;
  45584. private _onAfterRenderTargetsRenderObserver;
  45585. private _onAfterRenderObserver;
  45586. private _onBeforeDrawPhaseObserver;
  45587. private _onAfterDrawPhaseObserver;
  45588. private _onBeforeAnimationsObserver;
  45589. private _onBeforeParticlesRenderingObserver;
  45590. private _onAfterParticlesRenderingObserver;
  45591. private _onBeforeSpritesRenderingObserver;
  45592. private _onAfterSpritesRenderingObserver;
  45593. private _onBeforePhysicsObserver;
  45594. private _onAfterPhysicsObserver;
  45595. private _onAfterAnimationsObserver;
  45596. private _onBeforeCameraRenderObserver;
  45597. private _onAfterCameraRenderObserver;
  45598. /**
  45599. * Gets the perf counter used for active meshes evaluation time
  45600. */
  45601. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  45602. /**
  45603. * Gets the active meshes evaluation time capture status
  45604. */
  45605. /**
  45606. * Enable or disable the active meshes evaluation time capture
  45607. */
  45608. captureActiveMeshesEvaluationTime: boolean;
  45609. /**
  45610. * Gets the perf counter used for render targets render time
  45611. */
  45612. readonly renderTargetsRenderTimeCounter: PerfCounter;
  45613. /**
  45614. * Gets the render targets render time capture status
  45615. */
  45616. /**
  45617. * Enable or disable the render targets render time capture
  45618. */
  45619. captureRenderTargetsRenderTime: boolean;
  45620. /**
  45621. * Gets the perf counter used for particles render time
  45622. */
  45623. readonly particlesRenderTimeCounter: PerfCounter;
  45624. /**
  45625. * Gets the particles render time capture status
  45626. */
  45627. /**
  45628. * Enable or disable the particles render time capture
  45629. */
  45630. captureParticlesRenderTime: boolean;
  45631. /**
  45632. * Gets the perf counter used for sprites render time
  45633. */
  45634. readonly spritesRenderTimeCounter: PerfCounter;
  45635. /**
  45636. * Gets the sprites render time capture status
  45637. */
  45638. /**
  45639. * Enable or disable the sprites render time capture
  45640. */
  45641. captureSpritesRenderTime: boolean;
  45642. /**
  45643. * Gets the perf counter used for physics time
  45644. */
  45645. readonly physicsTimeCounter: PerfCounter;
  45646. /**
  45647. * Gets the physics time capture status
  45648. */
  45649. /**
  45650. * Enable or disable the physics time capture
  45651. */
  45652. capturePhysicsTime: boolean;
  45653. /**
  45654. * Gets the perf counter used for animations time
  45655. */
  45656. readonly animationsTimeCounter: PerfCounter;
  45657. /**
  45658. * Gets the animations time capture status
  45659. */
  45660. /**
  45661. * Enable or disable the animations time capture
  45662. */
  45663. captureAnimationsTime: boolean;
  45664. /**
  45665. * Gets the perf counter used for frame time capture
  45666. */
  45667. readonly frameTimeCounter: PerfCounter;
  45668. /**
  45669. * Gets the frame time capture status
  45670. */
  45671. /**
  45672. * Enable or disable the frame time capture
  45673. */
  45674. captureFrameTime: boolean;
  45675. /**
  45676. * Gets the perf counter used for inter-frames time capture
  45677. */
  45678. readonly interFrameTimeCounter: PerfCounter;
  45679. /**
  45680. * Gets the inter-frames time capture status
  45681. */
  45682. /**
  45683. * Enable or disable the inter-frames time capture
  45684. */
  45685. captureInterFrameTime: boolean;
  45686. /**
  45687. * Gets the perf counter used for render time capture
  45688. */
  45689. readonly renderTimeCounter: PerfCounter;
  45690. /**
  45691. * Gets the render time capture status
  45692. */
  45693. /**
  45694. * Enable or disable the render time capture
  45695. */
  45696. captureRenderTime: boolean;
  45697. /**
  45698. * Gets the perf counter used for camera render time capture
  45699. */
  45700. readonly cameraRenderTimeCounter: PerfCounter;
  45701. /**
  45702. * Gets the camera render time capture status
  45703. */
  45704. /**
  45705. * Enable or disable the camera render time capture
  45706. */
  45707. captureCameraRenderTime: boolean;
  45708. /**
  45709. * Gets the perf counter used for draw calls
  45710. */
  45711. readonly drawCallsCounter: PerfCounter;
  45712. /**
  45713. * Instantiates a new scene instrumentation.
  45714. * This class can be used to get instrumentation data from a Babylon engine
  45715. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45716. * @param scene Defines the scene to instrument
  45717. */
  45718. constructor(
  45719. /**
  45720. * Defines the scene to instrument
  45721. */
  45722. scene: Scene);
  45723. /**
  45724. * Dispose and release associated resources.
  45725. */
  45726. dispose(): void;
  45727. }
  45728. }
  45729. declare module BABYLON {
  45730. /** @hidden */
  45731. export var glowMapGenerationPixelShader: {
  45732. name: string;
  45733. shader: string;
  45734. };
  45735. }
  45736. declare module BABYLON {
  45737. /** @hidden */
  45738. export var glowMapGenerationVertexShader: {
  45739. name: string;
  45740. shader: string;
  45741. };
  45742. }
  45743. declare module BABYLON {
  45744. /**
  45745. * Effect layer options. This helps customizing the behaviour
  45746. * of the effect layer.
  45747. */
  45748. export interface IEffectLayerOptions {
  45749. /**
  45750. * Multiplication factor apply to the canvas size to compute the render target size
  45751. * used to generated the objects (the smaller the faster).
  45752. */
  45753. mainTextureRatio: number;
  45754. /**
  45755. * Enforces a fixed size texture to ensure effect stability across devices.
  45756. */
  45757. mainTextureFixedSize?: number;
  45758. /**
  45759. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  45760. */
  45761. alphaBlendingMode: number;
  45762. /**
  45763. * The camera attached to the layer.
  45764. */
  45765. camera: Nullable<Camera>;
  45766. /**
  45767. * The rendering group to draw the layer in.
  45768. */
  45769. renderingGroupId: number;
  45770. }
  45771. /**
  45772. * The effect layer Helps adding post process effect blended with the main pass.
  45773. *
  45774. * This can be for instance use to generate glow or higlight effects on the scene.
  45775. *
  45776. * The effect layer class can not be used directly and is intented to inherited from to be
  45777. * customized per effects.
  45778. */
  45779. export abstract class EffectLayer {
  45780. private _vertexBuffers;
  45781. private _indexBuffer;
  45782. private _cachedDefines;
  45783. private _effectLayerMapGenerationEffect;
  45784. private _effectLayerOptions;
  45785. private _mergeEffect;
  45786. protected _scene: Scene;
  45787. protected _engine: Engine;
  45788. protected _maxSize: number;
  45789. protected _mainTextureDesiredSize: ISize;
  45790. protected _mainTexture: RenderTargetTexture;
  45791. protected _shouldRender: boolean;
  45792. protected _postProcesses: PostProcess[];
  45793. protected _textures: BaseTexture[];
  45794. protected _emissiveTextureAndColor: {
  45795. texture: Nullable<BaseTexture>;
  45796. color: Color4;
  45797. };
  45798. /**
  45799. * The name of the layer
  45800. */
  45801. name: string;
  45802. /**
  45803. * The clear color of the texture used to generate the glow map.
  45804. */
  45805. neutralColor: Color4;
  45806. /**
  45807. * Specifies wether the highlight layer is enabled or not.
  45808. */
  45809. isEnabled: boolean;
  45810. /**
  45811. * Gets the camera attached to the layer.
  45812. */
  45813. readonly camera: Nullable<Camera>;
  45814. /**
  45815. * Gets the rendering group id the layer should render in.
  45816. */
  45817. readonly renderingGroupId: number;
  45818. /**
  45819. * An event triggered when the effect layer has been disposed.
  45820. */
  45821. onDisposeObservable: Observable<EffectLayer>;
  45822. /**
  45823. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  45824. */
  45825. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  45826. /**
  45827. * An event triggered when the generated texture is being merged in the scene.
  45828. */
  45829. onBeforeComposeObservable: Observable<EffectLayer>;
  45830. /**
  45831. * An event triggered when the generated texture has been merged in the scene.
  45832. */
  45833. onAfterComposeObservable: Observable<EffectLayer>;
  45834. /**
  45835. * An event triggered when the efffect layer changes its size.
  45836. */
  45837. onSizeChangedObservable: Observable<EffectLayer>;
  45838. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  45839. /**
  45840. * Instantiates a new effect Layer and references it in the scene.
  45841. * @param name The name of the layer
  45842. * @param scene The scene to use the layer in
  45843. */
  45844. constructor(
  45845. /** The Friendly of the effect in the scene */
  45846. name: string, scene: Scene);
  45847. /**
  45848. * Get the effect name of the layer.
  45849. * @return The effect name
  45850. */
  45851. abstract getEffectName(): string;
  45852. /**
  45853. * Checks for the readiness of the element composing the layer.
  45854. * @param subMesh the mesh to check for
  45855. * @param useInstances specify wether or not to use instances to render the mesh
  45856. * @return true if ready otherwise, false
  45857. */
  45858. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  45859. /**
  45860. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  45861. * @returns true if the effect requires stencil during the main canvas render pass.
  45862. */
  45863. abstract needStencil(): boolean;
  45864. /**
  45865. * Create the merge effect. This is the shader use to blit the information back
  45866. * to the main canvas at the end of the scene rendering.
  45867. * @returns The effect containing the shader used to merge the effect on the main canvas
  45868. */
  45869. protected abstract _createMergeEffect(): Effect;
  45870. /**
  45871. * Creates the render target textures and post processes used in the effect layer.
  45872. */
  45873. protected abstract _createTextureAndPostProcesses(): void;
  45874. /**
  45875. * Implementation specific of rendering the generating effect on the main canvas.
  45876. * @param effect The effect used to render through
  45877. */
  45878. protected abstract _internalRender(effect: Effect): void;
  45879. /**
  45880. * Sets the required values for both the emissive texture and and the main color.
  45881. */
  45882. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  45883. /**
  45884. * Free any resources and references associated to a mesh.
  45885. * Internal use
  45886. * @param mesh The mesh to free.
  45887. */
  45888. abstract _disposeMesh(mesh: Mesh): void;
  45889. /**
  45890. * Serializes this layer (Glow or Highlight for example)
  45891. * @returns a serialized layer object
  45892. */
  45893. abstract serialize?(): any;
  45894. /**
  45895. * Initializes the effect layer with the required options.
  45896. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  45897. */
  45898. protected _init(options: Partial<IEffectLayerOptions>): void;
  45899. /**
  45900. * Generates the index buffer of the full screen quad blending to the main canvas.
  45901. */
  45902. private _generateIndexBuffer;
  45903. /**
  45904. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  45905. */
  45906. private _genrateVertexBuffer;
  45907. /**
  45908. * Sets the main texture desired size which is the closest power of two
  45909. * of the engine canvas size.
  45910. */
  45911. private _setMainTextureSize;
  45912. /**
  45913. * Creates the main texture for the effect layer.
  45914. */
  45915. protected _createMainTexture(): void;
  45916. /**
  45917. * Adds specific effects defines.
  45918. * @param defines The defines to add specifics to.
  45919. */
  45920. protected _addCustomEffectDefines(defines: string[]): void;
  45921. /**
  45922. * Checks for the readiness of the element composing the layer.
  45923. * @param subMesh the mesh to check for
  45924. * @param useInstances specify wether or not to use instances to render the mesh
  45925. * @param emissiveTexture the associated emissive texture used to generate the glow
  45926. * @return true if ready otherwise, false
  45927. */
  45928. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  45929. /**
  45930. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  45931. */
  45932. render(): void;
  45933. /**
  45934. * Determine if a given mesh will be used in the current effect.
  45935. * @param mesh mesh to test
  45936. * @returns true if the mesh will be used
  45937. */
  45938. hasMesh(mesh: AbstractMesh): boolean;
  45939. /**
  45940. * Returns true if the layer contains information to display, otherwise false.
  45941. * @returns true if the glow layer should be rendered
  45942. */
  45943. shouldRender(): boolean;
  45944. /**
  45945. * Returns true if the mesh should render, otherwise false.
  45946. * @param mesh The mesh to render
  45947. * @returns true if it should render otherwise false
  45948. */
  45949. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  45950. /**
  45951. * Returns true if the mesh can be rendered, otherwise false.
  45952. * @param mesh The mesh to render
  45953. * @param material The material used on the mesh
  45954. * @returns true if it can be rendered otherwise false
  45955. */
  45956. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  45957. /**
  45958. * Returns true if the mesh should render, otherwise false.
  45959. * @param mesh The mesh to render
  45960. * @returns true if it should render otherwise false
  45961. */
  45962. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  45963. /**
  45964. * Renders the submesh passed in parameter to the generation map.
  45965. */
  45966. protected _renderSubMesh(subMesh: SubMesh): void;
  45967. /**
  45968. * Rebuild the required buffers.
  45969. * @hidden Internal use only.
  45970. */ rebuild(): void;
  45971. /**
  45972. * Dispose only the render target textures and post process.
  45973. */
  45974. private _disposeTextureAndPostProcesses;
  45975. /**
  45976. * Dispose the highlight layer and free resources.
  45977. */
  45978. dispose(): void;
  45979. /**
  45980. * Gets the class name of the effect layer
  45981. * @returns the string with the class name of the effect layer
  45982. */
  45983. getClassName(): string;
  45984. /**
  45985. * Creates an effect layer from parsed effect layer data
  45986. * @param parsedEffectLayer defines effect layer data
  45987. * @param scene defines the current scene
  45988. * @param rootUrl defines the root URL containing the effect layer information
  45989. * @returns a parsed effect Layer
  45990. */
  45991. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  45992. }
  45993. }
  45994. declare module BABYLON {
  45995. interface AbstractScene {
  45996. /**
  45997. * The list of effect layers (highlights/glow) added to the scene
  45998. * @see http://doc.babylonjs.com/how_to/highlight_layer
  45999. * @see http://doc.babylonjs.com/how_to/glow_layer
  46000. */
  46001. effectLayers: Array<EffectLayer>;
  46002. /**
  46003. * Removes the given effect layer from this scene.
  46004. * @param toRemove defines the effect layer to remove
  46005. * @returns the index of the removed effect layer
  46006. */
  46007. removeEffectLayer(toRemove: EffectLayer): number;
  46008. /**
  46009. * Adds the given effect layer to this scene
  46010. * @param newEffectLayer defines the effect layer to add
  46011. */
  46012. addEffectLayer(newEffectLayer: EffectLayer): void;
  46013. }
  46014. /**
  46015. * Defines the layer scene component responsible to manage any effect layers
  46016. * in a given scene.
  46017. */
  46018. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  46019. /**
  46020. * The component name helpfull to identify the component in the list of scene components.
  46021. */
  46022. readonly name: string;
  46023. /**
  46024. * The scene the component belongs to.
  46025. */
  46026. scene: Scene;
  46027. private _engine;
  46028. private _renderEffects;
  46029. private _needStencil;
  46030. private _previousStencilState;
  46031. /**
  46032. * Creates a new instance of the component for the given scene
  46033. * @param scene Defines the scene to register the component in
  46034. */
  46035. constructor(scene: Scene);
  46036. /**
  46037. * Registers the component in a given scene
  46038. */
  46039. register(): void;
  46040. /**
  46041. * Rebuilds the elements related to this component in case of
  46042. * context lost for instance.
  46043. */
  46044. rebuild(): void;
  46045. /**
  46046. * Serializes the component data to the specified json object
  46047. * @param serializationObject The object to serialize to
  46048. */
  46049. serialize(serializationObject: any): void;
  46050. /**
  46051. * Adds all the element from the container to the scene
  46052. * @param container the container holding the elements
  46053. */
  46054. addFromContainer(container: AbstractScene): void;
  46055. /**
  46056. * Removes all the elements in the container from the scene
  46057. * @param container contains the elements to remove
  46058. * @param dispose if the removed element should be disposed (default: false)
  46059. */
  46060. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46061. /**
  46062. * Disposes the component and the associated ressources.
  46063. */
  46064. dispose(): void;
  46065. private _isReadyForMesh;
  46066. private _renderMainTexture;
  46067. private _setStencil;
  46068. private _setStencilBack;
  46069. private _draw;
  46070. private _drawCamera;
  46071. private _drawRenderingGroup;
  46072. }
  46073. }
  46074. declare module BABYLON {
  46075. /** @hidden */
  46076. export var glowMapMergePixelShader: {
  46077. name: string;
  46078. shader: string;
  46079. };
  46080. }
  46081. declare module BABYLON {
  46082. /** @hidden */
  46083. export var glowMapMergeVertexShader: {
  46084. name: string;
  46085. shader: string;
  46086. };
  46087. }
  46088. declare module BABYLON {
  46089. interface AbstractScene {
  46090. /**
  46091. * Return a the first highlight layer of the scene with a given name.
  46092. * @param name The name of the highlight layer to look for.
  46093. * @return The highlight layer if found otherwise null.
  46094. */
  46095. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  46096. }
  46097. /**
  46098. * Glow layer options. This helps customizing the behaviour
  46099. * of the glow layer.
  46100. */
  46101. export interface IGlowLayerOptions {
  46102. /**
  46103. * Multiplication factor apply to the canvas size to compute the render target size
  46104. * used to generated the glowing objects (the smaller the faster).
  46105. */
  46106. mainTextureRatio: number;
  46107. /**
  46108. * Enforces a fixed size texture to ensure resize independant blur.
  46109. */
  46110. mainTextureFixedSize?: number;
  46111. /**
  46112. * How big is the kernel of the blur texture.
  46113. */
  46114. blurKernelSize: number;
  46115. /**
  46116. * The camera attached to the layer.
  46117. */
  46118. camera: Nullable<Camera>;
  46119. /**
  46120. * Enable MSAA by chosing the number of samples.
  46121. */
  46122. mainTextureSamples?: number;
  46123. /**
  46124. * The rendering group to draw the layer in.
  46125. */
  46126. renderingGroupId: number;
  46127. }
  46128. /**
  46129. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  46130. *
  46131. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46132. * glowy meshes to your scene.
  46133. *
  46134. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  46135. */
  46136. export class GlowLayer extends EffectLayer {
  46137. /**
  46138. * Effect Name of the layer.
  46139. */
  46140. static readonly EffectName: string;
  46141. /**
  46142. * The default blur kernel size used for the glow.
  46143. */
  46144. static DefaultBlurKernelSize: number;
  46145. /**
  46146. * The default texture size ratio used for the glow.
  46147. */
  46148. static DefaultTextureRatio: number;
  46149. /**
  46150. * Sets the kernel size of the blur.
  46151. */
  46152. /**
  46153. * Gets the kernel size of the blur.
  46154. */
  46155. blurKernelSize: number;
  46156. /**
  46157. * Sets the glow intensity.
  46158. */
  46159. /**
  46160. * Gets the glow intensity.
  46161. */
  46162. intensity: number;
  46163. private _options;
  46164. private _intensity;
  46165. private _horizontalBlurPostprocess1;
  46166. private _verticalBlurPostprocess1;
  46167. private _horizontalBlurPostprocess2;
  46168. private _verticalBlurPostprocess2;
  46169. private _blurTexture1;
  46170. private _blurTexture2;
  46171. private _postProcesses1;
  46172. private _postProcesses2;
  46173. private _includedOnlyMeshes;
  46174. private _excludedMeshes;
  46175. /**
  46176. * Callback used to let the user override the color selection on a per mesh basis
  46177. */
  46178. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  46179. /**
  46180. * Callback used to let the user override the texture selection on a per mesh basis
  46181. */
  46182. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  46183. /**
  46184. * Instantiates a new glow Layer and references it to the scene.
  46185. * @param name The name of the layer
  46186. * @param scene The scene to use the layer in
  46187. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  46188. */
  46189. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  46190. /**
  46191. * Get the effect name of the layer.
  46192. * @return The effect name
  46193. */
  46194. getEffectName(): string;
  46195. /**
  46196. * Create the merge effect. This is the shader use to blit the information back
  46197. * to the main canvas at the end of the scene rendering.
  46198. */
  46199. protected _createMergeEffect(): Effect;
  46200. /**
  46201. * Creates the render target textures and post processes used in the glow layer.
  46202. */
  46203. protected _createTextureAndPostProcesses(): void;
  46204. /**
  46205. * Checks for the readiness of the element composing the layer.
  46206. * @param subMesh the mesh to check for
  46207. * @param useInstances specify wether or not to use instances to render the mesh
  46208. * @param emissiveTexture the associated emissive texture used to generate the glow
  46209. * @return true if ready otherwise, false
  46210. */
  46211. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46212. /**
  46213. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46214. */
  46215. needStencil(): boolean;
  46216. /**
  46217. * Returns true if the mesh can be rendered, otherwise false.
  46218. * @param mesh The mesh to render
  46219. * @param material The material used on the mesh
  46220. * @returns true if it can be rendered otherwise false
  46221. */
  46222. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46223. /**
  46224. * Implementation specific of rendering the generating effect on the main canvas.
  46225. * @param effect The effect used to render through
  46226. */
  46227. protected _internalRender(effect: Effect): void;
  46228. /**
  46229. * Sets the required values for both the emissive texture and and the main color.
  46230. */
  46231. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46232. /**
  46233. * Returns true if the mesh should render, otherwise false.
  46234. * @param mesh The mesh to render
  46235. * @returns true if it should render otherwise false
  46236. */
  46237. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46238. /**
  46239. * Adds specific effects defines.
  46240. * @param defines The defines to add specifics to.
  46241. */
  46242. protected _addCustomEffectDefines(defines: string[]): void;
  46243. /**
  46244. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  46245. * @param mesh The mesh to exclude from the glow layer
  46246. */
  46247. addExcludedMesh(mesh: Mesh): void;
  46248. /**
  46249. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  46250. * @param mesh The mesh to remove
  46251. */
  46252. removeExcludedMesh(mesh: Mesh): void;
  46253. /**
  46254. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  46255. * @param mesh The mesh to include in the glow layer
  46256. */
  46257. addIncludedOnlyMesh(mesh: Mesh): void;
  46258. /**
  46259. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  46260. * @param mesh The mesh to remove
  46261. */
  46262. removeIncludedOnlyMesh(mesh: Mesh): void;
  46263. /**
  46264. * Determine if a given mesh will be used in the glow layer
  46265. * @param mesh The mesh to test
  46266. * @returns true if the mesh will be highlighted by the current glow layer
  46267. */
  46268. hasMesh(mesh: AbstractMesh): boolean;
  46269. /**
  46270. * Free any resources and references associated to a mesh.
  46271. * Internal use
  46272. * @param mesh The mesh to free.
  46273. * @hidden
  46274. */ disposeMesh(mesh: Mesh): void;
  46275. /**
  46276. * Gets the class name of the effect layer
  46277. * @returns the string with the class name of the effect layer
  46278. */
  46279. getClassName(): string;
  46280. /**
  46281. * Serializes this glow layer
  46282. * @returns a serialized glow layer object
  46283. */
  46284. serialize(): any;
  46285. /**
  46286. * Creates a Glow Layer from parsed glow layer data
  46287. * @param parsedGlowLayer defines glow layer data
  46288. * @param scene defines the current scene
  46289. * @param rootUrl defines the root URL containing the glow layer information
  46290. * @returns a parsed Glow Layer
  46291. */
  46292. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  46293. }
  46294. }
  46295. declare module BABYLON {
  46296. /** @hidden */
  46297. export var glowBlurPostProcessPixelShader: {
  46298. name: string;
  46299. shader: string;
  46300. };
  46301. }
  46302. declare module BABYLON {
  46303. interface AbstractScene {
  46304. /**
  46305. * Return a the first highlight layer of the scene with a given name.
  46306. * @param name The name of the highlight layer to look for.
  46307. * @return The highlight layer if found otherwise null.
  46308. */
  46309. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  46310. }
  46311. /**
  46312. * Highlight layer options. This helps customizing the behaviour
  46313. * of the highlight layer.
  46314. */
  46315. export interface IHighlightLayerOptions {
  46316. /**
  46317. * Multiplication factor apply to the canvas size to compute the render target size
  46318. * used to generated the glowing objects (the smaller the faster).
  46319. */
  46320. mainTextureRatio: number;
  46321. /**
  46322. * Enforces a fixed size texture to ensure resize independant blur.
  46323. */
  46324. mainTextureFixedSize?: number;
  46325. /**
  46326. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  46327. * of the picture to blur (the smaller the faster).
  46328. */
  46329. blurTextureSizeRatio: number;
  46330. /**
  46331. * How big in texel of the blur texture is the vertical blur.
  46332. */
  46333. blurVerticalSize: number;
  46334. /**
  46335. * How big in texel of the blur texture is the horizontal blur.
  46336. */
  46337. blurHorizontalSize: number;
  46338. /**
  46339. * Alpha blending mode used to apply the blur. Default is combine.
  46340. */
  46341. alphaBlendingMode: number;
  46342. /**
  46343. * The camera attached to the layer.
  46344. */
  46345. camera: Nullable<Camera>;
  46346. /**
  46347. * Should we display highlight as a solid stroke?
  46348. */
  46349. isStroke?: boolean;
  46350. /**
  46351. * The rendering group to draw the layer in.
  46352. */
  46353. renderingGroupId: number;
  46354. }
  46355. /**
  46356. * The highlight layer Helps adding a glow effect around a mesh.
  46357. *
  46358. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46359. * glowy meshes to your scene.
  46360. *
  46361. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  46362. */
  46363. export class HighlightLayer extends EffectLayer {
  46364. name: string;
  46365. /**
  46366. * Effect Name of the highlight layer.
  46367. */
  46368. static readonly EffectName: string;
  46369. /**
  46370. * The neutral color used during the preparation of the glow effect.
  46371. * This is black by default as the blend operation is a blend operation.
  46372. */
  46373. static NeutralColor: Color4;
  46374. /**
  46375. * Stencil value used for glowing meshes.
  46376. */
  46377. static GlowingMeshStencilReference: number;
  46378. /**
  46379. * Stencil value used for the other meshes in the scene.
  46380. */
  46381. static NormalMeshStencilReference: number;
  46382. /**
  46383. * Specifies whether or not the inner glow is ACTIVE in the layer.
  46384. */
  46385. innerGlow: boolean;
  46386. /**
  46387. * Specifies whether or not the outer glow is ACTIVE in the layer.
  46388. */
  46389. outerGlow: boolean;
  46390. /**
  46391. * Specifies the horizontal size of the blur.
  46392. */
  46393. /**
  46394. * Gets the horizontal size of the blur.
  46395. */
  46396. blurHorizontalSize: number;
  46397. /**
  46398. * Specifies the vertical size of the blur.
  46399. */
  46400. /**
  46401. * Gets the vertical size of the blur.
  46402. */
  46403. blurVerticalSize: number;
  46404. /**
  46405. * An event triggered when the highlight layer is being blurred.
  46406. */
  46407. onBeforeBlurObservable: Observable<HighlightLayer>;
  46408. /**
  46409. * An event triggered when the highlight layer has been blurred.
  46410. */
  46411. onAfterBlurObservable: Observable<HighlightLayer>;
  46412. private _instanceGlowingMeshStencilReference;
  46413. private _options;
  46414. private _downSamplePostprocess;
  46415. private _horizontalBlurPostprocess;
  46416. private _verticalBlurPostprocess;
  46417. private _blurTexture;
  46418. private _meshes;
  46419. private _excludedMeshes;
  46420. /**
  46421. * Instantiates a new highlight Layer and references it to the scene..
  46422. * @param name The name of the layer
  46423. * @param scene The scene to use the layer in
  46424. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  46425. */
  46426. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  46427. /**
  46428. * Get the effect name of the layer.
  46429. * @return The effect name
  46430. */
  46431. getEffectName(): string;
  46432. /**
  46433. * Create the merge effect. This is the shader use to blit the information back
  46434. * to the main canvas at the end of the scene rendering.
  46435. */
  46436. protected _createMergeEffect(): Effect;
  46437. /**
  46438. * Creates the render target textures and post processes used in the highlight layer.
  46439. */
  46440. protected _createTextureAndPostProcesses(): void;
  46441. /**
  46442. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46443. */
  46444. needStencil(): boolean;
  46445. /**
  46446. * Checks for the readiness of the element composing the layer.
  46447. * @param subMesh the mesh to check for
  46448. * @param useInstances specify wether or not to use instances to render the mesh
  46449. * @param emissiveTexture the associated emissive texture used to generate the glow
  46450. * @return true if ready otherwise, false
  46451. */
  46452. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46453. /**
  46454. * Implementation specific of rendering the generating effect on the main canvas.
  46455. * @param effect The effect used to render through
  46456. */
  46457. protected _internalRender(effect: Effect): void;
  46458. /**
  46459. * Returns true if the layer contains information to display, otherwise false.
  46460. */
  46461. shouldRender(): boolean;
  46462. /**
  46463. * Returns true if the mesh should render, otherwise false.
  46464. * @param mesh The mesh to render
  46465. * @returns true if it should render otherwise false
  46466. */
  46467. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46468. /**
  46469. * Sets the required values for both the emissive texture and and the main color.
  46470. */
  46471. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46472. /**
  46473. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  46474. * @param mesh The mesh to exclude from the highlight layer
  46475. */
  46476. addExcludedMesh(mesh: Mesh): void;
  46477. /**
  46478. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  46479. * @param mesh The mesh to highlight
  46480. */
  46481. removeExcludedMesh(mesh: Mesh): void;
  46482. /**
  46483. * Determine if a given mesh will be highlighted by the current HighlightLayer
  46484. * @param mesh mesh to test
  46485. * @returns true if the mesh will be highlighted by the current HighlightLayer
  46486. */
  46487. hasMesh(mesh: AbstractMesh): boolean;
  46488. /**
  46489. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  46490. * @param mesh The mesh to highlight
  46491. * @param color The color of the highlight
  46492. * @param glowEmissiveOnly Extract the glow from the emissive texture
  46493. */
  46494. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  46495. /**
  46496. * Remove a mesh from the highlight layer in order to make it stop glowing.
  46497. * @param mesh The mesh to highlight
  46498. */
  46499. removeMesh(mesh: Mesh): void;
  46500. /**
  46501. * Force the stencil to the normal expected value for none glowing parts
  46502. */
  46503. private _defaultStencilReference;
  46504. /**
  46505. * Free any resources and references associated to a mesh.
  46506. * Internal use
  46507. * @param mesh The mesh to free.
  46508. * @hidden
  46509. */ disposeMesh(mesh: Mesh): void;
  46510. /**
  46511. * Dispose the highlight layer and free resources.
  46512. */
  46513. dispose(): void;
  46514. /**
  46515. * Gets the class name of the effect layer
  46516. * @returns the string with the class name of the effect layer
  46517. */
  46518. getClassName(): string;
  46519. /**
  46520. * Serializes this Highlight layer
  46521. * @returns a serialized Highlight layer object
  46522. */
  46523. serialize(): any;
  46524. /**
  46525. * Creates a Highlight layer from parsed Highlight layer data
  46526. * @param parsedHightlightLayer defines the Highlight layer data
  46527. * @param scene defines the current scene
  46528. * @param rootUrl defines the root URL containing the Highlight layer information
  46529. * @returns a parsed Highlight layer
  46530. */
  46531. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  46532. }
  46533. }
  46534. declare module BABYLON {
  46535. /** @hidden */
  46536. export var lensFlarePixelShader: {
  46537. name: string;
  46538. shader: string;
  46539. };
  46540. }
  46541. declare module BABYLON {
  46542. /** @hidden */
  46543. export var lensFlareVertexShader: {
  46544. name: string;
  46545. shader: string;
  46546. };
  46547. }
  46548. declare module BABYLON {
  46549. /**
  46550. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46551. * It is usually composed of several `lensFlare`.
  46552. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46553. */
  46554. export class LensFlareSystem {
  46555. /**
  46556. * Define the name of the lens flare system
  46557. */
  46558. name: string;
  46559. /**
  46560. * List of lens flares used in this system.
  46561. */
  46562. lensFlares: LensFlare[];
  46563. /**
  46564. * Define a limit from the border the lens flare can be visible.
  46565. */
  46566. borderLimit: number;
  46567. /**
  46568. * Define a viewport border we do not want to see the lens flare in.
  46569. */
  46570. viewportBorder: number;
  46571. /**
  46572. * Define a predicate which could limit the list of meshes able to occlude the effect.
  46573. */
  46574. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46575. /**
  46576. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  46577. */
  46578. layerMask: number;
  46579. /**
  46580. * Define the id of the lens flare system in the scene.
  46581. * (equal to name by default)
  46582. */
  46583. id: string;
  46584. private _scene;
  46585. private _emitter;
  46586. private _vertexBuffers;
  46587. private _indexBuffer;
  46588. private _effect;
  46589. private _positionX;
  46590. private _positionY;
  46591. private _isEnabled;
  46592. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  46593. /**
  46594. * Instantiates a lens flare system.
  46595. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46596. * It is usually composed of several `lensFlare`.
  46597. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46598. * @param name Define the name of the lens flare system in the scene
  46599. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  46600. * @param scene Define the scene the lens flare system belongs to
  46601. */
  46602. constructor(
  46603. /**
  46604. * Define the name of the lens flare system
  46605. */
  46606. name: string, emitter: any, scene: Scene);
  46607. /**
  46608. * Define if the lens flare system is enabled.
  46609. */
  46610. isEnabled: boolean;
  46611. /**
  46612. * Get the scene the effects belongs to.
  46613. * @returns the scene holding the lens flare system
  46614. */
  46615. getScene(): Scene;
  46616. /**
  46617. * Get the emitter of the lens flare system.
  46618. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46619. * @returns the emitter of the lens flare system
  46620. */
  46621. getEmitter(): any;
  46622. /**
  46623. * Set the emitter of the lens flare system.
  46624. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46625. * @param newEmitter Define the new emitter of the system
  46626. */
  46627. setEmitter(newEmitter: any): void;
  46628. /**
  46629. * Get the lens flare system emitter position.
  46630. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  46631. * @returns the position
  46632. */
  46633. getEmitterPosition(): Vector3;
  46634. /**
  46635. * @hidden
  46636. */
  46637. computeEffectivePosition(globalViewport: Viewport): boolean;
  46638. /** @hidden */ isVisible(): boolean;
  46639. /**
  46640. * @hidden
  46641. */
  46642. render(): boolean;
  46643. /**
  46644. * Dispose and release the lens flare with its associated resources.
  46645. */
  46646. dispose(): void;
  46647. /**
  46648. * Parse a lens flare system from a JSON repressentation
  46649. * @param parsedLensFlareSystem Define the JSON to parse
  46650. * @param scene Define the scene the parsed system should be instantiated in
  46651. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  46652. * @returns the parsed system
  46653. */
  46654. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  46655. /**
  46656. * Serialize the current Lens Flare System into a JSON representation.
  46657. * @returns the serialized JSON
  46658. */
  46659. serialize(): any;
  46660. }
  46661. }
  46662. declare module BABYLON {
  46663. /**
  46664. * This represents one of the lens effect in a `lensFlareSystem`.
  46665. * It controls one of the indiviual texture used in the effect.
  46666. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46667. */
  46668. export class LensFlare {
  46669. /**
  46670. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46671. */
  46672. size: number;
  46673. /**
  46674. * 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.
  46675. */
  46676. position: number;
  46677. /**
  46678. * Define the lens color.
  46679. */
  46680. color: Color3;
  46681. /**
  46682. * Define the lens texture.
  46683. */
  46684. texture: Nullable<Texture>;
  46685. /**
  46686. * Define the alpha mode to render this particular lens.
  46687. */
  46688. alphaMode: number;
  46689. private _system;
  46690. /**
  46691. * Creates a new Lens Flare.
  46692. * This represents one of the lens effect in a `lensFlareSystem`.
  46693. * It controls one of the indiviual texture used in the effect.
  46694. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46695. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  46696. * @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.
  46697. * @param color Define the lens color
  46698. * @param imgUrl Define the lens texture url
  46699. * @param system Define the `lensFlareSystem` this flare is part of
  46700. * @returns The newly created Lens Flare
  46701. */
  46702. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  46703. /**
  46704. * Instantiates a new Lens Flare.
  46705. * This represents one of the lens effect in a `lensFlareSystem`.
  46706. * It controls one of the indiviual texture used in the effect.
  46707. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46708. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  46709. * @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.
  46710. * @param color Define the lens color
  46711. * @param imgUrl Define the lens texture url
  46712. * @param system Define the `lensFlareSystem` this flare is part of
  46713. */
  46714. constructor(
  46715. /**
  46716. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46717. */
  46718. size: number,
  46719. /**
  46720. * 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.
  46721. */
  46722. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  46723. /**
  46724. * Dispose and release the lens flare with its associated resources.
  46725. */
  46726. dispose(): void;
  46727. }
  46728. }
  46729. declare module BABYLON {
  46730. interface AbstractScene {
  46731. /**
  46732. * The list of lens flare system added to the scene
  46733. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46734. */
  46735. lensFlareSystems: Array<LensFlareSystem>;
  46736. /**
  46737. * Removes the given lens flare system from this scene.
  46738. * @param toRemove The lens flare system to remove
  46739. * @returns The index of the removed lens flare system
  46740. */
  46741. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  46742. /**
  46743. * Adds the given lens flare system to this scene
  46744. * @param newLensFlareSystem The lens flare system to add
  46745. */
  46746. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  46747. /**
  46748. * Gets a lens flare system using its name
  46749. * @param name defines the name to look for
  46750. * @returns the lens flare system or null if not found
  46751. */
  46752. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  46753. /**
  46754. * Gets a lens flare system using its id
  46755. * @param id defines the id to look for
  46756. * @returns the lens flare system or null if not found
  46757. */
  46758. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  46759. }
  46760. /**
  46761. * Defines the lens flare scene component responsible to manage any lens flares
  46762. * in a given scene.
  46763. */
  46764. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  46765. /**
  46766. * The component name helpfull to identify the component in the list of scene components.
  46767. */
  46768. readonly name: string;
  46769. /**
  46770. * The scene the component belongs to.
  46771. */
  46772. scene: Scene;
  46773. /**
  46774. * Creates a new instance of the component for the given scene
  46775. * @param scene Defines the scene to register the component in
  46776. */
  46777. constructor(scene: Scene);
  46778. /**
  46779. * Registers the component in a given scene
  46780. */
  46781. register(): void;
  46782. /**
  46783. * Rebuilds the elements related to this component in case of
  46784. * context lost for instance.
  46785. */
  46786. rebuild(): void;
  46787. /**
  46788. * Adds all the element from the container to the scene
  46789. * @param container the container holding the elements
  46790. */
  46791. addFromContainer(container: AbstractScene): void;
  46792. /**
  46793. * Removes all the elements in the container from the scene
  46794. * @param container contains the elements to remove
  46795. * @param dispose if the removed element should be disposed (default: false)
  46796. */
  46797. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46798. /**
  46799. * Serializes the component data to the specified json object
  46800. * @param serializationObject The object to serialize to
  46801. */
  46802. serialize(serializationObject: any): void;
  46803. /**
  46804. * Disposes the component and the associated ressources.
  46805. */
  46806. dispose(): void;
  46807. private _draw;
  46808. }
  46809. }
  46810. declare module BABYLON {
  46811. /**
  46812. * Defines the shadow generator component responsible to manage any shadow generators
  46813. * in a given scene.
  46814. */
  46815. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  46816. /**
  46817. * The component name helpfull to identify the component in the list of scene components.
  46818. */
  46819. readonly name: string;
  46820. /**
  46821. * The scene the component belongs to.
  46822. */
  46823. scene: Scene;
  46824. /**
  46825. * Creates a new instance of the component for the given scene
  46826. * @param scene Defines the scene to register the component in
  46827. */
  46828. constructor(scene: Scene);
  46829. /**
  46830. * Registers the component in a given scene
  46831. */
  46832. register(): void;
  46833. /**
  46834. * Rebuilds the elements related to this component in case of
  46835. * context lost for instance.
  46836. */
  46837. rebuild(): void;
  46838. /**
  46839. * Serializes the component data to the specified json object
  46840. * @param serializationObject The object to serialize to
  46841. */
  46842. serialize(serializationObject: any): void;
  46843. /**
  46844. * Adds all the element from the container to the scene
  46845. * @param container the container holding the elements
  46846. */
  46847. addFromContainer(container: AbstractScene): void;
  46848. /**
  46849. * Removes all the elements in the container from the scene
  46850. * @param container contains the elements to remove
  46851. * @param dispose if the removed element should be disposed (default: false)
  46852. */
  46853. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46854. /**
  46855. * Rebuilds the elements related to this component in case of
  46856. * context lost for instance.
  46857. */
  46858. dispose(): void;
  46859. private _gatherRenderTargets;
  46860. }
  46861. }
  46862. declare module BABYLON {
  46863. /**
  46864. * A point light is a light defined by an unique point in world space.
  46865. * The light is emitted in every direction from this point.
  46866. * A good example of a point light is a standard light bulb.
  46867. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46868. */
  46869. export class PointLight extends ShadowLight {
  46870. private _shadowAngle;
  46871. /**
  46872. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46873. * This specifies what angle the shadow will use to be created.
  46874. *
  46875. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46876. */
  46877. /**
  46878. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46879. * This specifies what angle the shadow will use to be created.
  46880. *
  46881. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46882. */
  46883. shadowAngle: number;
  46884. /**
  46885. * Gets the direction if it has been set.
  46886. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46887. */
  46888. /**
  46889. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46890. */
  46891. direction: Vector3;
  46892. /**
  46893. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  46894. * A PointLight emits the light in every direction.
  46895. * It can cast shadows.
  46896. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  46897. * ```javascript
  46898. * var pointLight = new PointLight("pl", camera.position, scene);
  46899. * ```
  46900. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46901. * @param name The light friendly name
  46902. * @param position The position of the point light in the scene
  46903. * @param scene The scene the lights belongs to
  46904. */
  46905. constructor(name: string, position: Vector3, scene: Scene);
  46906. /**
  46907. * Returns the string "PointLight"
  46908. * @returns the class name
  46909. */
  46910. getClassName(): string;
  46911. /**
  46912. * Returns the integer 0.
  46913. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46914. */
  46915. getTypeID(): number;
  46916. /**
  46917. * Specifies wether or not the shadowmap should be a cube texture.
  46918. * @returns true if the shadowmap needs to be a cube texture.
  46919. */
  46920. needCube(): boolean;
  46921. /**
  46922. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  46923. * @param faceIndex The index of the face we are computed the direction to generate shadow
  46924. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  46925. */
  46926. getShadowDirection(faceIndex?: number): Vector3;
  46927. /**
  46928. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  46929. * - fov = PI / 2
  46930. * - aspect ratio : 1.0
  46931. * - z-near and far equal to the active camera minZ and maxZ.
  46932. * Returns the PointLight.
  46933. */
  46934. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46935. protected _buildUniformLayout(): void;
  46936. /**
  46937. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  46938. * @param effect The effect to update
  46939. * @param lightIndex The index of the light in the effect to update
  46940. * @returns The point light
  46941. */
  46942. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  46943. /**
  46944. * Prepares the list of defines specific to the light type.
  46945. * @param defines the list of defines
  46946. * @param lightIndex defines the index of the light for the effect
  46947. */
  46948. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46949. }
  46950. }
  46951. declare module BABYLON {
  46952. /**
  46953. * Header information of HDR texture files.
  46954. */
  46955. export interface HDRInfo {
  46956. /**
  46957. * The height of the texture in pixels.
  46958. */
  46959. height: number;
  46960. /**
  46961. * The width of the texture in pixels.
  46962. */
  46963. width: number;
  46964. /**
  46965. * The index of the beginning of the data in the binary file.
  46966. */
  46967. dataPosition: number;
  46968. }
  46969. /**
  46970. * This groups tools to convert HDR texture to native colors array.
  46971. */
  46972. export class HDRTools {
  46973. private static Ldexp;
  46974. private static Rgbe2float;
  46975. private static readStringLine;
  46976. /**
  46977. * Reads header information from an RGBE texture stored in a native array.
  46978. * More information on this format are available here:
  46979. * https://en.wikipedia.org/wiki/RGBE_image_format
  46980. *
  46981. * @param uint8array The binary file stored in native array.
  46982. * @return The header information.
  46983. */
  46984. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  46985. /**
  46986. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  46987. * This RGBE texture needs to store the information as a panorama.
  46988. *
  46989. * More information on this format are available here:
  46990. * https://en.wikipedia.org/wiki/RGBE_image_format
  46991. *
  46992. * @param buffer The binary file stored in an array buffer.
  46993. * @param size The expected size of the extracted cubemap.
  46994. * @return The Cube Map information.
  46995. */
  46996. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  46997. /**
  46998. * Returns the pixels data extracted from an RGBE texture.
  46999. * This pixels will be stored left to right up to down in the R G B order in one array.
  47000. *
  47001. * More information on this format are available here:
  47002. * https://en.wikipedia.org/wiki/RGBE_image_format
  47003. *
  47004. * @param uint8array The binary file stored in an array buffer.
  47005. * @param hdrInfo The header information of the file.
  47006. * @return The pixels data in RGB right to left up to down order.
  47007. */
  47008. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  47009. private static RGBE_ReadPixels_RLE;
  47010. }
  47011. }
  47012. declare module BABYLON {
  47013. /**
  47014. * This represents a texture coming from an HDR input.
  47015. *
  47016. * The only supported format is currently panorama picture stored in RGBE format.
  47017. * Example of such files can be found on HDRLib: http://hdrlib.com/
  47018. */
  47019. export class HDRCubeTexture extends BaseTexture {
  47020. private static _facesMapping;
  47021. private _generateHarmonics;
  47022. private _noMipmap;
  47023. private _textureMatrix;
  47024. private _size;
  47025. private _onLoad;
  47026. private _onError;
  47027. /**
  47028. * The texture URL.
  47029. */
  47030. url: string;
  47031. /**
  47032. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47033. */
  47034. coordinatesMode: number;
  47035. protected _isBlocking: boolean;
  47036. /**
  47037. * Sets wether or not the texture is blocking during loading.
  47038. */
  47039. /**
  47040. * Gets wether or not the texture is blocking during loading.
  47041. */
  47042. isBlocking: boolean;
  47043. protected _rotationY: number;
  47044. /**
  47045. * Sets texture matrix rotation angle around Y axis in radians.
  47046. */
  47047. /**
  47048. * Gets texture matrix rotation angle around Y axis radians.
  47049. */
  47050. rotationY: number;
  47051. /**
  47052. * Gets or sets the center of the bounding box associated with the cube texture
  47053. * It must define where the camera used to render the texture was set
  47054. */
  47055. boundingBoxPosition: Vector3;
  47056. private _boundingBoxSize;
  47057. /**
  47058. * Gets or sets the size of the bounding box associated with the cube texture
  47059. * When defined, the cubemap will switch to local mode
  47060. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47061. * @example https://www.babylonjs-playground.com/#RNASML
  47062. */
  47063. boundingBoxSize: Vector3;
  47064. /**
  47065. * Instantiates an HDRTexture from the following parameters.
  47066. *
  47067. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47068. * @param scene The scene the texture will be used in
  47069. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47070. * @param noMipmap Forces to not generate the mipmap if true
  47071. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47072. * @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)
  47073. * @param reserved Reserved flag for internal use.
  47074. */
  47075. 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>);
  47076. /**
  47077. * Get the current class name of the texture useful for serialization or dynamic coding.
  47078. * @returns "HDRCubeTexture"
  47079. */
  47080. getClassName(): string;
  47081. /**
  47082. * Occurs when the file is raw .hdr file.
  47083. */
  47084. private loadTexture;
  47085. clone(): HDRCubeTexture;
  47086. delayLoad(): void;
  47087. /**
  47088. * Get the texture reflection matrix used to rotate/transform the reflection.
  47089. * @returns the reflection matrix
  47090. */
  47091. getReflectionTextureMatrix(): Matrix;
  47092. /**
  47093. * Set the texture reflection matrix used to rotate/transform the reflection.
  47094. * @param value Define the reflection matrix to set
  47095. */
  47096. setReflectionTextureMatrix(value: Matrix): void;
  47097. /**
  47098. * Parses a JSON representation of an HDR Texture in order to create the texture
  47099. * @param parsedTexture Define the JSON representation
  47100. * @param scene Define the scene the texture should be created in
  47101. * @param rootUrl Define the root url in case we need to load relative dependencies
  47102. * @returns the newly created texture after parsing
  47103. */
  47104. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47105. serialize(): any;
  47106. }
  47107. }
  47108. declare module BABYLON {
  47109. /**
  47110. * Class used to control physics engine
  47111. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47112. */
  47113. export class PhysicsEngine implements IPhysicsEngine {
  47114. private _physicsPlugin;
  47115. /**
  47116. * Global value used to control the smallest number supported by the simulation
  47117. */
  47118. static Epsilon: number;
  47119. private _impostors;
  47120. private _joints;
  47121. /**
  47122. * Gets the gravity vector used by the simulation
  47123. */
  47124. gravity: Vector3;
  47125. /**
  47126. * Factory used to create the default physics plugin.
  47127. * @returns The default physics plugin
  47128. */
  47129. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  47130. /**
  47131. * Creates a new Physics Engine
  47132. * @param gravity defines the gravity vector used by the simulation
  47133. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  47134. */
  47135. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  47136. /**
  47137. * Sets the gravity vector used by the simulation
  47138. * @param gravity defines the gravity vector to use
  47139. */
  47140. setGravity(gravity: Vector3): void;
  47141. /**
  47142. * Set the time step of the physics engine.
  47143. * Default is 1/60.
  47144. * To slow it down, enter 1/600 for example.
  47145. * To speed it up, 1/30
  47146. * @param newTimeStep defines the new timestep to apply to this world.
  47147. */
  47148. setTimeStep(newTimeStep?: number): void;
  47149. /**
  47150. * Get the time step of the physics engine.
  47151. * @returns the current time step
  47152. */
  47153. getTimeStep(): number;
  47154. /**
  47155. * Release all resources
  47156. */
  47157. dispose(): void;
  47158. /**
  47159. * Gets the name of the current physics plugin
  47160. * @returns the name of the plugin
  47161. */
  47162. getPhysicsPluginName(): string;
  47163. /**
  47164. * Adding a new impostor for the impostor tracking.
  47165. * This will be done by the impostor itself.
  47166. * @param impostor the impostor to add
  47167. */
  47168. addImpostor(impostor: PhysicsImpostor): void;
  47169. /**
  47170. * Remove an impostor from the engine.
  47171. * This impostor and its mesh will not longer be updated by the physics engine.
  47172. * @param impostor the impostor to remove
  47173. */
  47174. removeImpostor(impostor: PhysicsImpostor): void;
  47175. /**
  47176. * Add a joint to the physics engine
  47177. * @param mainImpostor defines the main impostor to which the joint is added.
  47178. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47179. * @param joint defines the joint that will connect both impostors.
  47180. */
  47181. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47182. /**
  47183. * Removes a joint from the simulation
  47184. * @param mainImpostor defines the impostor used with the joint
  47185. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47186. * @param joint defines the joint to remove
  47187. */
  47188. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47189. /**
  47190. * Called by the scene. No need to call it.
  47191. * @param delta defines the timespam between frames
  47192. */ step(delta: number): void;
  47193. /**
  47194. * Gets the current plugin used to run the simulation
  47195. * @returns current plugin
  47196. */
  47197. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47198. /**
  47199. * Gets the list of physic impostors
  47200. * @returns an array of PhysicsImpostor
  47201. */
  47202. getImpostors(): Array<PhysicsImpostor>;
  47203. /**
  47204. * Gets the impostor for a physics enabled object
  47205. * @param object defines the object impersonated by the impostor
  47206. * @returns the PhysicsImpostor or null if not found
  47207. */
  47208. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47209. /**
  47210. * Gets the impostor for a physics body object
  47211. * @param body defines physics body used by the impostor
  47212. * @returns the PhysicsImpostor or null if not found
  47213. */
  47214. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47215. /**
  47216. * Does a raycast in the physics world
  47217. * @param from when should the ray start?
  47218. * @param to when should the ray end?
  47219. * @returns PhysicsRaycastResult
  47220. */
  47221. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47222. }
  47223. }
  47224. declare module BABYLON {
  47225. /** @hidden */
  47226. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47227. private _useDeltaForWorldStep;
  47228. world: any;
  47229. name: string;
  47230. private _physicsMaterials;
  47231. private _fixedTimeStep;
  47232. private _cannonRaycastResult;
  47233. private _raycastResult;
  47234. private _removeAfterStep;
  47235. BJSCANNON: any;
  47236. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  47237. setGravity(gravity: Vector3): void;
  47238. setTimeStep(timeStep: number): void;
  47239. getTimeStep(): number;
  47240. executeStep(delta: number): void;
  47241. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47242. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47243. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47244. private _processChildMeshes;
  47245. removePhysicsBody(impostor: PhysicsImpostor): void;
  47246. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47247. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47248. private _addMaterial;
  47249. private _checkWithEpsilon;
  47250. private _createShape;
  47251. private _createHeightmap;
  47252. private _minus90X;
  47253. private _plus90X;
  47254. private _tmpPosition;
  47255. private _tmpDeltaPosition;
  47256. private _tmpUnityRotation;
  47257. private _updatePhysicsBodyTransformation;
  47258. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47259. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47260. isSupported(): boolean;
  47261. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47262. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47263. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47264. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47265. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47266. getBodyMass(impostor: PhysicsImpostor): number;
  47267. getBodyFriction(impostor: PhysicsImpostor): number;
  47268. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47269. getBodyRestitution(impostor: PhysicsImpostor): number;
  47270. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47271. sleepBody(impostor: PhysicsImpostor): void;
  47272. wakeUpBody(impostor: PhysicsImpostor): void;
  47273. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  47274. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47275. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47276. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47277. getRadius(impostor: PhysicsImpostor): number;
  47278. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47279. dispose(): void;
  47280. private _extendNamespace;
  47281. /**
  47282. * Does a raycast in the physics world
  47283. * @param from when should the ray start?
  47284. * @param to when should the ray end?
  47285. * @returns PhysicsRaycastResult
  47286. */
  47287. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47288. }
  47289. }
  47290. declare module BABYLON {
  47291. /** @hidden */
  47292. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  47293. world: any;
  47294. name: string;
  47295. BJSOIMO: any;
  47296. private _raycastResult;
  47297. constructor(iterations?: number, oimoInjection?: any);
  47298. setGravity(gravity: Vector3): void;
  47299. setTimeStep(timeStep: number): void;
  47300. getTimeStep(): number;
  47301. private _tmpImpostorsArray;
  47302. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47303. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47304. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47305. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47306. private _tmpPositionVector;
  47307. removePhysicsBody(impostor: PhysicsImpostor): void;
  47308. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47309. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47310. isSupported(): boolean;
  47311. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47312. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47313. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47314. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47315. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47316. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47317. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47318. getBodyMass(impostor: PhysicsImpostor): number;
  47319. getBodyFriction(impostor: PhysicsImpostor): number;
  47320. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47321. getBodyRestitution(impostor: PhysicsImpostor): number;
  47322. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47323. sleepBody(impostor: PhysicsImpostor): void;
  47324. wakeUpBody(impostor: PhysicsImpostor): void;
  47325. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47326. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  47327. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47328. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47329. getRadius(impostor: PhysicsImpostor): number;
  47330. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47331. dispose(): void;
  47332. /**
  47333. * Does a raycast in the physics world
  47334. * @param from when should the ray start?
  47335. * @param to when should the ray end?
  47336. * @returns PhysicsRaycastResult
  47337. */
  47338. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47339. }
  47340. }
  47341. declare module BABYLON {
  47342. /**
  47343. * Class containing static functions to help procedurally build meshes
  47344. */
  47345. export class RibbonBuilder {
  47346. /**
  47347. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  47348. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  47349. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  47350. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  47351. * * 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
  47352. * * 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
  47353. * * 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
  47354. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47355. * * If you create a double-sided mesh, you can choose what parts of 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
  47356. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47357. * * 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
  47358. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  47359. * * 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
  47360. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  47361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47362. * @param name defines the name of the mesh
  47363. * @param options defines the options used to create the mesh
  47364. * @param scene defines the hosting scene
  47365. * @returns the ribbon mesh
  47366. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  47367. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47368. */
  47369. static CreateRibbon(name: string, options: {
  47370. pathArray: Vector3[][];
  47371. closeArray?: boolean;
  47372. closePath?: boolean;
  47373. offset?: number;
  47374. updatable?: boolean;
  47375. sideOrientation?: number;
  47376. frontUVs?: Vector4;
  47377. backUVs?: Vector4;
  47378. instance?: Mesh;
  47379. invertUV?: boolean;
  47380. uvs?: Vector2[];
  47381. colors?: Color4[];
  47382. }, scene?: Nullable<Scene>): Mesh;
  47383. }
  47384. }
  47385. declare module BABYLON {
  47386. /**
  47387. * Class containing static functions to help procedurally build meshes
  47388. */
  47389. export class ShapeBuilder {
  47390. /**
  47391. * 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.
  47392. * * 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.
  47393. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47394. * * 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.
  47395. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  47396. * * 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
  47397. * * 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
  47398. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  47399. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47400. * * If you create a double-sided mesh, you can choose what parts of 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
  47401. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  47402. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47403. * @param name defines the name of the mesh
  47404. * @param options defines the options used to create the mesh
  47405. * @param scene defines the hosting scene
  47406. * @returns the extruded shape mesh
  47407. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47408. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47409. */
  47410. static ExtrudeShape(name: string, options: {
  47411. shape: Vector3[];
  47412. path: Vector3[];
  47413. scale?: number;
  47414. rotation?: number;
  47415. cap?: number;
  47416. updatable?: boolean;
  47417. sideOrientation?: number;
  47418. frontUVs?: Vector4;
  47419. backUVs?: Vector4;
  47420. instance?: Mesh;
  47421. invertUV?: boolean;
  47422. }, scene?: Nullable<Scene>): Mesh;
  47423. /**
  47424. * Creates an custom extruded shape mesh.
  47425. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  47426. * * 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.
  47427. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47428. * * 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
  47429. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  47430. * * 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
  47431. * * It must returns a float value that will be the scale value applied to the shape on each path point
  47432. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  47433. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  47434. * * 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
  47435. * * 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
  47436. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  47437. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47438. * * If you create a double-sided mesh, you can choose what parts of 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
  47439. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47441. * @param name defines the name of the mesh
  47442. * @param options defines the options used to create the mesh
  47443. * @param scene defines the hosting scene
  47444. * @returns the custom extruded shape mesh
  47445. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  47446. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47447. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47448. */
  47449. static ExtrudeShapeCustom(name: string, options: {
  47450. shape: Vector3[];
  47451. path: Vector3[];
  47452. scaleFunction?: any;
  47453. rotationFunction?: any;
  47454. ribbonCloseArray?: boolean;
  47455. ribbonClosePath?: boolean;
  47456. cap?: number;
  47457. updatable?: boolean;
  47458. sideOrientation?: number;
  47459. frontUVs?: Vector4;
  47460. backUVs?: Vector4;
  47461. instance?: Mesh;
  47462. invertUV?: boolean;
  47463. }, scene?: Nullable<Scene>): Mesh;
  47464. private static _ExtrudeShapeGeneric;
  47465. }
  47466. }
  47467. declare module BABYLON {
  47468. /**
  47469. * AmmoJS Physics plugin
  47470. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  47471. * @see https://github.com/kripken/ammo.js/
  47472. */
  47473. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  47474. private _useDeltaForWorldStep;
  47475. /**
  47476. * Reference to the Ammo library
  47477. */
  47478. bjsAMMO: any;
  47479. /**
  47480. * Created ammoJS world which physics bodies are added to
  47481. */
  47482. world: any;
  47483. /**
  47484. * Name of the plugin
  47485. */
  47486. name: string;
  47487. private _timeStep;
  47488. private _fixedTimeStep;
  47489. private _maxSteps;
  47490. private _tmpQuaternion;
  47491. private _tmpAmmoTransform;
  47492. private _tmpAmmoQuaternion;
  47493. private _tmpAmmoConcreteContactResultCallback;
  47494. private _collisionConfiguration;
  47495. private _dispatcher;
  47496. private _overlappingPairCache;
  47497. private _solver;
  47498. private _softBodySolver;
  47499. private _tmpAmmoVectorA;
  47500. private _tmpAmmoVectorB;
  47501. private _tmpAmmoVectorC;
  47502. private _tmpAmmoVectorD;
  47503. private _tmpContactCallbackResult;
  47504. private _tmpAmmoVectorRCA;
  47505. private _tmpAmmoVectorRCB;
  47506. private _raycastResult;
  47507. private static readonly DISABLE_COLLISION_FLAG;
  47508. private static readonly KINEMATIC_FLAG;
  47509. private static readonly DISABLE_DEACTIVATION_FLAG;
  47510. /**
  47511. * Initializes the ammoJS plugin
  47512. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  47513. * @param ammoInjection can be used to inject your own ammo reference
  47514. */
  47515. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  47516. /**
  47517. * Sets the gravity of the physics world (m/(s^2))
  47518. * @param gravity Gravity to set
  47519. */
  47520. setGravity(gravity: Vector3): void;
  47521. /**
  47522. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  47523. * @param timeStep timestep to use in seconds
  47524. */
  47525. setTimeStep(timeStep: number): void;
  47526. /**
  47527. * 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)
  47528. * @param fixedTimeStep fixedTimeStep to use in seconds
  47529. */
  47530. setFixedTimeStep(fixedTimeStep: number): void;
  47531. /**
  47532. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  47533. * @param maxSteps the maximum number of steps by the physics engine per frame
  47534. */
  47535. setMaxSteps(maxSteps: number): void;
  47536. /**
  47537. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  47538. * @returns the current timestep in seconds
  47539. */
  47540. getTimeStep(): number;
  47541. private _isImpostorInContact;
  47542. private _isImpostorPairInContact;
  47543. private _stepSimulation;
  47544. /**
  47545. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  47546. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  47547. * After the step the babylon meshes are set to the position of the physics imposters
  47548. * @param delta amount of time to step forward
  47549. * @param impostors array of imposters to update before/after the step
  47550. */
  47551. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47552. /**
  47553. * Update babylon mesh to match physics world object
  47554. * @param impostor imposter to match
  47555. */
  47556. private _afterSoftStep;
  47557. /**
  47558. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  47559. * @param impostor imposter to match
  47560. */
  47561. private _ropeStep;
  47562. /**
  47563. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  47564. * @param impostor imposter to match
  47565. */
  47566. private _softbodyOrClothStep;
  47567. private _tmpVector;
  47568. private _tmpMatrix;
  47569. /**
  47570. * Applies an impulse on the imposter
  47571. * @param impostor imposter to apply impulse to
  47572. * @param force amount of force to be applied to the imposter
  47573. * @param contactPoint the location to apply the impulse on the imposter
  47574. */
  47575. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47576. /**
  47577. * Applies a force on the imposter
  47578. * @param impostor imposter to apply force
  47579. * @param force amount of force to be applied to the imposter
  47580. * @param contactPoint the location to apply the force on the imposter
  47581. */
  47582. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47583. /**
  47584. * Creates a physics body using the plugin
  47585. * @param impostor the imposter to create the physics body on
  47586. */
  47587. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47588. /**
  47589. * Removes the physics body from the imposter and disposes of the body's memory
  47590. * @param impostor imposter to remove the physics body from
  47591. */
  47592. removePhysicsBody(impostor: PhysicsImpostor): void;
  47593. /**
  47594. * Generates a joint
  47595. * @param impostorJoint the imposter joint to create the joint with
  47596. */
  47597. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47598. /**
  47599. * Removes a joint
  47600. * @param impostorJoint the imposter joint to remove the joint from
  47601. */
  47602. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47603. private _addMeshVerts;
  47604. /**
  47605. * Initialise the soft body vertices to match its object's (mesh) vertices
  47606. * Softbody vertices (nodes) are in world space and to match this
  47607. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  47608. * @param impostor to create the softbody for
  47609. */
  47610. private _softVertexData;
  47611. /**
  47612. * Create an impostor's soft body
  47613. * @param impostor to create the softbody for
  47614. */
  47615. private _createSoftbody;
  47616. /**
  47617. * Create cloth for an impostor
  47618. * @param impostor to create the softbody for
  47619. */
  47620. private _createCloth;
  47621. /**
  47622. * Create rope for an impostor
  47623. * @param impostor to create the softbody for
  47624. */
  47625. private _createRope;
  47626. private _addHullVerts;
  47627. private _createShape;
  47628. /**
  47629. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  47630. * @param impostor imposter containing the physics body and babylon object
  47631. */
  47632. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47633. /**
  47634. * Sets the babylon object's position/rotation from the physics body's position/rotation
  47635. * @param impostor imposter containing the physics body and babylon object
  47636. * @param newPosition new position
  47637. * @param newRotation new rotation
  47638. */
  47639. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47640. /**
  47641. * If this plugin is supported
  47642. * @returns true if its supported
  47643. */
  47644. isSupported(): boolean;
  47645. /**
  47646. * Sets the linear velocity of the physics body
  47647. * @param impostor imposter to set the velocity on
  47648. * @param velocity velocity to set
  47649. */
  47650. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47651. /**
  47652. * Sets the angular velocity of the physics body
  47653. * @param impostor imposter to set the velocity on
  47654. * @param velocity velocity to set
  47655. */
  47656. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47657. /**
  47658. * gets the linear velocity
  47659. * @param impostor imposter to get linear velocity from
  47660. * @returns linear velocity
  47661. */
  47662. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47663. /**
  47664. * gets the angular velocity
  47665. * @param impostor imposter to get angular velocity from
  47666. * @returns angular velocity
  47667. */
  47668. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47669. /**
  47670. * Sets the mass of physics body
  47671. * @param impostor imposter to set the mass on
  47672. * @param mass mass to set
  47673. */
  47674. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47675. /**
  47676. * Gets the mass of the physics body
  47677. * @param impostor imposter to get the mass from
  47678. * @returns mass
  47679. */
  47680. getBodyMass(impostor: PhysicsImpostor): number;
  47681. /**
  47682. * Gets friction of the impostor
  47683. * @param impostor impostor to get friction from
  47684. * @returns friction value
  47685. */
  47686. getBodyFriction(impostor: PhysicsImpostor): number;
  47687. /**
  47688. * Sets friction of the impostor
  47689. * @param impostor impostor to set friction on
  47690. * @param friction friction value
  47691. */
  47692. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47693. /**
  47694. * Gets restitution of the impostor
  47695. * @param impostor impostor to get restitution from
  47696. * @returns restitution value
  47697. */
  47698. getBodyRestitution(impostor: PhysicsImpostor): number;
  47699. /**
  47700. * Sets resitution of the impostor
  47701. * @param impostor impostor to set resitution on
  47702. * @param restitution resitution value
  47703. */
  47704. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47705. /**
  47706. * Gets pressure inside the impostor
  47707. * @param impostor impostor to get pressure from
  47708. * @returns pressure value
  47709. */
  47710. getBodyPressure(impostor: PhysicsImpostor): number;
  47711. /**
  47712. * Sets pressure inside a soft body impostor
  47713. * Cloth and rope must remain 0 pressure
  47714. * @param impostor impostor to set pressure on
  47715. * @param pressure pressure value
  47716. */
  47717. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  47718. /**
  47719. * Gets stiffness of the impostor
  47720. * @param impostor impostor to get stiffness from
  47721. * @returns pressure value
  47722. */
  47723. getBodyStiffness(impostor: PhysicsImpostor): number;
  47724. /**
  47725. * Sets stiffness of the impostor
  47726. * @param impostor impostor to set stiffness on
  47727. * @param stiffness stiffness value from 0 to 1
  47728. */
  47729. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  47730. /**
  47731. * Gets velocityIterations of the impostor
  47732. * @param impostor impostor to get velocity iterations from
  47733. * @returns velocityIterations value
  47734. */
  47735. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  47736. /**
  47737. * Sets velocityIterations of the impostor
  47738. * @param impostor impostor to set velocity iterations on
  47739. * @param velocityIterations velocityIterations value
  47740. */
  47741. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  47742. /**
  47743. * Gets positionIterations of the impostor
  47744. * @param impostor impostor to get position iterations from
  47745. * @returns positionIterations value
  47746. */
  47747. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  47748. /**
  47749. * Sets positionIterations of the impostor
  47750. * @param impostor impostor to set position on
  47751. * @param positionIterations positionIterations value
  47752. */
  47753. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  47754. /**
  47755. * Append an anchor to a cloth object
  47756. * @param impostor is the cloth impostor to add anchor to
  47757. * @param otherImpostor is the rigid impostor to anchor to
  47758. * @param width ratio across width from 0 to 1
  47759. * @param height ratio up height from 0 to 1
  47760. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  47761. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  47762. */
  47763. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  47764. /**
  47765. * Append an hook to a rope object
  47766. * @param impostor is the rope impostor to add hook to
  47767. * @param otherImpostor is the rigid impostor to hook to
  47768. * @param length ratio along the rope from 0 to 1
  47769. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  47770. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  47771. */
  47772. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  47773. /**
  47774. * Sleeps the physics body and stops it from being active
  47775. * @param impostor impostor to sleep
  47776. */
  47777. sleepBody(impostor: PhysicsImpostor): void;
  47778. /**
  47779. * Activates the physics body
  47780. * @param impostor impostor to activate
  47781. */
  47782. wakeUpBody(impostor: PhysicsImpostor): void;
  47783. /**
  47784. * Updates the distance parameters of the joint
  47785. * @param joint joint to update
  47786. * @param maxDistance maximum distance of the joint
  47787. * @param minDistance minimum distance of the joint
  47788. */
  47789. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47790. /**
  47791. * Sets a motor on the joint
  47792. * @param joint joint to set motor on
  47793. * @param speed speed of the motor
  47794. * @param maxForce maximum force of the motor
  47795. * @param motorIndex index of the motor
  47796. */
  47797. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47798. /**
  47799. * Sets the motors limit
  47800. * @param joint joint to set limit on
  47801. * @param upperLimit upper limit
  47802. * @param lowerLimit lower limit
  47803. */
  47804. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47805. /**
  47806. * Syncs the position and rotation of a mesh with the impostor
  47807. * @param mesh mesh to sync
  47808. * @param impostor impostor to update the mesh with
  47809. */
  47810. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47811. /**
  47812. * Gets the radius of the impostor
  47813. * @param impostor impostor to get radius from
  47814. * @returns the radius
  47815. */
  47816. getRadius(impostor: PhysicsImpostor): number;
  47817. /**
  47818. * Gets the box size of the impostor
  47819. * @param impostor impostor to get box size from
  47820. * @param result the resulting box size
  47821. */
  47822. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47823. /**
  47824. * Disposes of the impostor
  47825. */
  47826. dispose(): void;
  47827. /**
  47828. * Does a raycast in the physics world
  47829. * @param from when should the ray start?
  47830. * @param to when should the ray end?
  47831. * @returns PhysicsRaycastResult
  47832. */
  47833. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47834. }
  47835. }
  47836. declare module BABYLON {
  47837. interface AbstractScene {
  47838. /**
  47839. * The list of reflection probes added to the scene
  47840. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47841. */
  47842. reflectionProbes: Array<ReflectionProbe>;
  47843. /**
  47844. * Removes the given reflection probe from this scene.
  47845. * @param toRemove The reflection probe to remove
  47846. * @returns The index of the removed reflection probe
  47847. */
  47848. removeReflectionProbe(toRemove: ReflectionProbe): number;
  47849. /**
  47850. * Adds the given reflection probe to this scene.
  47851. * @param newReflectionProbe The reflection probe to add
  47852. */
  47853. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  47854. }
  47855. /**
  47856. * Class used to generate realtime reflection / refraction cube textures
  47857. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47858. */
  47859. export class ReflectionProbe {
  47860. /** defines the name of the probe */
  47861. name: string;
  47862. private _scene;
  47863. private _renderTargetTexture;
  47864. private _projectionMatrix;
  47865. private _viewMatrix;
  47866. private _target;
  47867. private _add;
  47868. private _attachedMesh;
  47869. private _invertYAxis;
  47870. /** Gets or sets probe position (center of the cube map) */
  47871. position: Vector3;
  47872. /**
  47873. * Creates a new reflection probe
  47874. * @param name defines the name of the probe
  47875. * @param size defines the texture resolution (for each face)
  47876. * @param scene defines the hosting scene
  47877. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  47878. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  47879. */
  47880. constructor(
  47881. /** defines the name of the probe */
  47882. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  47883. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  47884. samples: number;
  47885. /** Gets or sets the refresh rate to use (on every frame by default) */
  47886. refreshRate: number;
  47887. /**
  47888. * Gets the hosting scene
  47889. * @returns a Scene
  47890. */
  47891. getScene(): Scene;
  47892. /** Gets the internal CubeTexture used to render to */
  47893. readonly cubeTexture: RenderTargetTexture;
  47894. /** Gets the list of meshes to render */
  47895. readonly renderList: Nullable<AbstractMesh[]>;
  47896. /**
  47897. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  47898. * @param mesh defines the mesh to attach to
  47899. */
  47900. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47901. /**
  47902. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  47903. * @param renderingGroupId The rendering group id corresponding to its index
  47904. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47905. */
  47906. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  47907. /**
  47908. * Clean all associated resources
  47909. */
  47910. dispose(): void;
  47911. /**
  47912. * Converts the reflection probe information to a readable string for debug purpose.
  47913. * @param fullDetails Supports for multiple levels of logging within scene loading
  47914. * @returns the human readable reflection probe info
  47915. */
  47916. toString(fullDetails?: boolean): string;
  47917. /**
  47918. * Get the class name of the relfection probe.
  47919. * @returns "ReflectionProbe"
  47920. */
  47921. getClassName(): string;
  47922. /**
  47923. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  47924. * @returns The JSON representation of the texture
  47925. */
  47926. serialize(): any;
  47927. /**
  47928. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  47929. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  47930. * @param scene Define the scene the parsed reflection probe should be instantiated in
  47931. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  47932. * @returns The parsed reflection probe if successful
  47933. */
  47934. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  47935. }
  47936. }
  47937. declare module BABYLON {
  47938. /** @hidden */
  47939. export var _BabylonLoaderRegistered: boolean;
  47940. }
  47941. declare module BABYLON {
  47942. /**
  47943. * The Physically based simple base material of BJS.
  47944. *
  47945. * This enables better naming and convention enforcements on top of the pbrMaterial.
  47946. * It is used as the base class for both the specGloss and metalRough conventions.
  47947. */
  47948. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  47949. /**
  47950. * Number of Simultaneous lights allowed on the material.
  47951. */
  47952. maxSimultaneousLights: number;
  47953. /**
  47954. * If sets to true, disables all the lights affecting the material.
  47955. */
  47956. disableLighting: boolean;
  47957. /**
  47958. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  47959. */
  47960. environmentTexture: BaseTexture;
  47961. /**
  47962. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47963. */
  47964. invertNormalMapX: boolean;
  47965. /**
  47966. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47967. */
  47968. invertNormalMapY: boolean;
  47969. /**
  47970. * Normal map used in the model.
  47971. */
  47972. normalTexture: BaseTexture;
  47973. /**
  47974. * Emissivie color used to self-illuminate the model.
  47975. */
  47976. emissiveColor: Color3;
  47977. /**
  47978. * Emissivie texture used to self-illuminate the model.
  47979. */
  47980. emissiveTexture: BaseTexture;
  47981. /**
  47982. * Occlusion Channel Strenght.
  47983. */
  47984. occlusionStrength: number;
  47985. /**
  47986. * Occlusion Texture of the material (adding extra occlusion effects).
  47987. */
  47988. occlusionTexture: BaseTexture;
  47989. /**
  47990. * Defines the alpha limits in alpha test mode.
  47991. */
  47992. alphaCutOff: number;
  47993. /**
  47994. * Gets the current double sided mode.
  47995. */
  47996. /**
  47997. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47998. */
  47999. doubleSided: boolean;
  48000. /**
  48001. * Stores the pre-calculated light information of a mesh in a texture.
  48002. */
  48003. lightmapTexture: BaseTexture;
  48004. /**
  48005. * If true, the light map contains occlusion information instead of lighting info.
  48006. */
  48007. useLightmapAsShadowmap: boolean;
  48008. /**
  48009. * Instantiates a new PBRMaterial instance.
  48010. *
  48011. * @param name The material name
  48012. * @param scene The scene the material will be use in.
  48013. */
  48014. constructor(name: string, scene: Scene);
  48015. getClassName(): string;
  48016. }
  48017. }
  48018. declare module BABYLON {
  48019. /**
  48020. * The PBR material of BJS following the metal roughness convention.
  48021. *
  48022. * This fits to the PBR convention in the GLTF definition:
  48023. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  48024. */
  48025. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  48026. /**
  48027. * The base color has two different interpretations depending on the value of metalness.
  48028. * When the material is a metal, the base color is the specific measured reflectance value
  48029. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  48030. * of the material.
  48031. */
  48032. baseColor: Color3;
  48033. /**
  48034. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  48035. * well as opacity information in the alpha channel.
  48036. */
  48037. baseTexture: BaseTexture;
  48038. /**
  48039. * Specifies the metallic scalar value of the material.
  48040. * Can also be used to scale the metalness values of the metallic texture.
  48041. */
  48042. metallic: number;
  48043. /**
  48044. * Specifies the roughness scalar value of the material.
  48045. * Can also be used to scale the roughness values of the metallic texture.
  48046. */
  48047. roughness: number;
  48048. /**
  48049. * Texture containing both the metallic value in the B channel and the
  48050. * roughness value in the G channel to keep better precision.
  48051. */
  48052. metallicRoughnessTexture: BaseTexture;
  48053. /**
  48054. * Instantiates a new PBRMetalRoughnessMaterial instance.
  48055. *
  48056. * @param name The material name
  48057. * @param scene The scene the material will be use in.
  48058. */
  48059. constructor(name: string, scene: Scene);
  48060. /**
  48061. * Return the currrent class name of the material.
  48062. */
  48063. getClassName(): string;
  48064. /**
  48065. * Makes a duplicate of the current material.
  48066. * @param name - name to use for the new material.
  48067. */
  48068. clone(name: string): PBRMetallicRoughnessMaterial;
  48069. /**
  48070. * Serialize the material to a parsable JSON object.
  48071. */
  48072. serialize(): any;
  48073. /**
  48074. * Parses a JSON object correponding to the serialize function.
  48075. */
  48076. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  48077. }
  48078. }
  48079. declare module BABYLON {
  48080. /**
  48081. * The PBR material of BJS following the specular glossiness convention.
  48082. *
  48083. * This fits to the PBR convention in the GLTF definition:
  48084. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  48085. */
  48086. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  48087. /**
  48088. * Specifies the diffuse color of the material.
  48089. */
  48090. diffuseColor: Color3;
  48091. /**
  48092. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  48093. * channel.
  48094. */
  48095. diffuseTexture: BaseTexture;
  48096. /**
  48097. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  48098. */
  48099. specularColor: Color3;
  48100. /**
  48101. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  48102. */
  48103. glossiness: number;
  48104. /**
  48105. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  48106. */
  48107. specularGlossinessTexture: BaseTexture;
  48108. /**
  48109. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  48110. *
  48111. * @param name The material name
  48112. * @param scene The scene the material will be use in.
  48113. */
  48114. constructor(name: string, scene: Scene);
  48115. /**
  48116. * Return the currrent class name of the material.
  48117. */
  48118. getClassName(): string;
  48119. /**
  48120. * Makes a duplicate of the current material.
  48121. * @param name - name to use for the new material.
  48122. */
  48123. clone(name: string): PBRSpecularGlossinessMaterial;
  48124. /**
  48125. * Serialize the material to a parsable JSON object.
  48126. */
  48127. serialize(): any;
  48128. /**
  48129. * Parses a JSON object correponding to the serialize function.
  48130. */
  48131. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  48132. }
  48133. }
  48134. declare module BABYLON {
  48135. /**
  48136. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  48137. * It can help converting any input color in a desired output one. This can then be used to create effects
  48138. * from sepia, black and white to sixties or futuristic rendering...
  48139. *
  48140. * The only supported format is currently 3dl.
  48141. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  48142. */
  48143. export class ColorGradingTexture extends BaseTexture {
  48144. /**
  48145. * The current texture matrix. (will always be identity in color grading texture)
  48146. */
  48147. private _textureMatrix;
  48148. /**
  48149. * The texture URL.
  48150. */
  48151. url: string;
  48152. /**
  48153. * Empty line regex stored for GC.
  48154. */
  48155. private static _noneEmptyLineRegex;
  48156. private _engine;
  48157. /**
  48158. * Instantiates a ColorGradingTexture from the following parameters.
  48159. *
  48160. * @param url The location of the color gradind data (currently only supporting 3dl)
  48161. * @param scene The scene the texture will be used in
  48162. */
  48163. constructor(url: string, scene: Scene);
  48164. /**
  48165. * Returns the texture matrix used in most of the material.
  48166. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  48167. */
  48168. getTextureMatrix(): Matrix;
  48169. /**
  48170. * Occurs when the file being loaded is a .3dl LUT file.
  48171. */
  48172. private load3dlTexture;
  48173. /**
  48174. * Starts the loading process of the texture.
  48175. */
  48176. private loadTexture;
  48177. /**
  48178. * Clones the color gradind texture.
  48179. */
  48180. clone(): ColorGradingTexture;
  48181. /**
  48182. * Called during delayed load for textures.
  48183. */
  48184. delayLoad(): void;
  48185. /**
  48186. * Parses a color grading texture serialized by Babylon.
  48187. * @param parsedTexture The texture information being parsedTexture
  48188. * @param scene The scene to load the texture in
  48189. * @param rootUrl The root url of the data assets to load
  48190. * @return A color gradind texture
  48191. */
  48192. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  48193. /**
  48194. * Serializes the LUT texture to json format.
  48195. */
  48196. serialize(): any;
  48197. }
  48198. }
  48199. declare module BABYLON {
  48200. /**
  48201. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  48202. */
  48203. export class EquiRectangularCubeTexture extends BaseTexture {
  48204. /** The six faces of the cube. */
  48205. private static _FacesMapping;
  48206. private _noMipmap;
  48207. private _onLoad;
  48208. private _onError;
  48209. /** The size of the cubemap. */
  48210. private _size;
  48211. /** The buffer of the image. */
  48212. private _buffer;
  48213. /** The width of the input image. */
  48214. private _width;
  48215. /** The height of the input image. */
  48216. private _height;
  48217. /** The URL to the image. */
  48218. url: string;
  48219. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  48220. coordinatesMode: number;
  48221. /**
  48222. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  48223. * @param url The location of the image
  48224. * @param scene The scene the texture will be used in
  48225. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48226. * @param noMipmap Forces to not generate the mipmap if true
  48227. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  48228. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  48229. * @param onLoad — defines a callback called when texture is loaded
  48230. * @param onError — defines a callback called if there is an error
  48231. */
  48232. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  48233. /**
  48234. * Load the image data, by putting the image on a canvas and extracting its buffer.
  48235. */
  48236. private loadImage;
  48237. /**
  48238. * Convert the image buffer into a cubemap and create a CubeTexture.
  48239. */
  48240. private loadTexture;
  48241. /**
  48242. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  48243. * @param buffer The ArrayBuffer that should be converted.
  48244. * @returns The buffer as Float32Array.
  48245. */
  48246. private getFloat32ArrayFromArrayBuffer;
  48247. /**
  48248. * Get the current class name of the texture useful for serialization or dynamic coding.
  48249. * @returns "EquiRectangularCubeTexture"
  48250. */
  48251. getClassName(): string;
  48252. /**
  48253. * Create a clone of the current EquiRectangularCubeTexture and return it.
  48254. * @returns A clone of the current EquiRectangularCubeTexture.
  48255. */
  48256. clone(): EquiRectangularCubeTexture;
  48257. }
  48258. }
  48259. declare module BABYLON {
  48260. /**
  48261. * Based on jsTGALoader - Javascript loader for TGA file
  48262. * By Vincent Thibault
  48263. * @see http://blog.robrowser.com/javascript-tga-loader.html
  48264. */
  48265. export class TGATools {
  48266. private static _TYPE_INDEXED;
  48267. private static _TYPE_RGB;
  48268. private static _TYPE_GREY;
  48269. private static _TYPE_RLE_INDEXED;
  48270. private static _TYPE_RLE_RGB;
  48271. private static _TYPE_RLE_GREY;
  48272. private static _ORIGIN_MASK;
  48273. private static _ORIGIN_SHIFT;
  48274. private static _ORIGIN_BL;
  48275. private static _ORIGIN_BR;
  48276. private static _ORIGIN_UL;
  48277. private static _ORIGIN_UR;
  48278. /**
  48279. * Gets the header of a TGA file
  48280. * @param data defines the TGA data
  48281. * @returns the header
  48282. */
  48283. static GetTGAHeader(data: Uint8Array): any;
  48284. /**
  48285. * Uploads TGA content to a Babylon Texture
  48286. * @hidden
  48287. */
  48288. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  48289. /** @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;
  48290. /** @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;
  48291. /** @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;
  48292. /** @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;
  48293. /** @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;
  48294. /** @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;
  48295. }
  48296. }
  48297. declare module BABYLON {
  48298. /**
  48299. * Implementation of the TGA Texture Loader.
  48300. * @hidden
  48301. */
  48302. export class _TGATextureLoader implements IInternalTextureLoader {
  48303. /**
  48304. * Defines wether the loader supports cascade loading the different faces.
  48305. */
  48306. readonly supportCascades: boolean;
  48307. /**
  48308. * This returns if the loader support the current file information.
  48309. * @param extension defines the file extension of the file being loaded
  48310. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48311. * @param fallback defines the fallback internal texture if any
  48312. * @param isBase64 defines whether the texture is encoded as a base64
  48313. * @param isBuffer defines whether the texture data are stored as a buffer
  48314. * @returns true if the loader can load the specified file
  48315. */
  48316. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48317. /**
  48318. * Transform the url before loading if required.
  48319. * @param rootUrl the url of the texture
  48320. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48321. * @returns the transformed texture
  48322. */
  48323. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48324. /**
  48325. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48326. * @param rootUrl the url of the texture
  48327. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48328. * @returns the fallback texture
  48329. */
  48330. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48331. /**
  48332. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48333. * @param data contains the texture data
  48334. * @param texture defines the BabylonJS internal texture
  48335. * @param createPolynomials will be true if polynomials have been requested
  48336. * @param onLoad defines the callback to trigger once the texture is ready
  48337. * @param onError defines the callback to trigger in case of error
  48338. */
  48339. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48340. /**
  48341. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48342. * @param data contains the texture data
  48343. * @param texture defines the BabylonJS internal texture
  48344. * @param callback defines the method to call once ready to upload
  48345. */
  48346. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48347. }
  48348. }
  48349. declare module BABYLON {
  48350. /**
  48351. * 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.
  48352. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48353. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48354. */
  48355. export class CustomProceduralTexture extends ProceduralTexture {
  48356. private _animate;
  48357. private _time;
  48358. private _config;
  48359. private _texturePath;
  48360. /**
  48361. * Instantiates a new Custom Procedural Texture.
  48362. * 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.
  48363. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48364. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48365. * @param name Define the name of the texture
  48366. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  48367. * @param size Define the size of the texture to create
  48368. * @param scene Define the scene the texture belongs to
  48369. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48370. * @param generateMipMaps Define if the texture should creates mip maps or not
  48371. */
  48372. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48373. private _loadJson;
  48374. /**
  48375. * Is the texture ready to be used ? (rendered at least once)
  48376. * @returns true if ready, otherwise, false.
  48377. */
  48378. isReady(): boolean;
  48379. /**
  48380. * Render the texture to its associated render target.
  48381. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48382. */
  48383. render(useCameraPostProcess?: boolean): void;
  48384. /**
  48385. * Update the list of dependant textures samplers in the shader.
  48386. */
  48387. updateTextures(): void;
  48388. /**
  48389. * Update the uniform values of the procedural texture in the shader.
  48390. */
  48391. updateShaderUniforms(): void;
  48392. /**
  48393. * Define if the texture animates or not.
  48394. */
  48395. animate: boolean;
  48396. }
  48397. }
  48398. declare module BABYLON {
  48399. /** @hidden */
  48400. export var noisePixelShader: {
  48401. name: string;
  48402. shader: string;
  48403. };
  48404. }
  48405. declare module BABYLON {
  48406. /**
  48407. * Class used to generate noise procedural textures
  48408. */
  48409. export class NoiseProceduralTexture extends ProceduralTexture {
  48410. private _time;
  48411. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  48412. brightness: number;
  48413. /** Defines the number of octaves to process */
  48414. octaves: number;
  48415. /** Defines the level of persistence (0.8 by default) */
  48416. persistence: number;
  48417. /** Gets or sets animation speed factor (default is 1) */
  48418. animationSpeedFactor: number;
  48419. /**
  48420. * Creates a new NoiseProceduralTexture
  48421. * @param name defines the name fo the texture
  48422. * @param size defines the size of the texture (default is 256)
  48423. * @param scene defines the hosting scene
  48424. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  48425. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  48426. */
  48427. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48428. private _updateShaderUniforms;
  48429. protected _getDefines(): string;
  48430. /** Generate the current state of the procedural texture */
  48431. render(useCameraPostProcess?: boolean): void;
  48432. /**
  48433. * Serializes this noise procedural texture
  48434. * @returns a serialized noise procedural texture object
  48435. */
  48436. serialize(): any;
  48437. /**
  48438. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  48439. * @param parsedTexture defines parsed texture data
  48440. * @param scene defines the current scene
  48441. * @param rootUrl defines the root URL containing noise procedural texture information
  48442. * @returns a parsed NoiseProceduralTexture
  48443. */
  48444. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  48445. }
  48446. }
  48447. declare module BABYLON {
  48448. /**
  48449. * Raw cube texture where the raw buffers are passed in
  48450. */
  48451. export class RawCubeTexture extends CubeTexture {
  48452. /**
  48453. * Creates a cube texture where the raw buffers are passed in.
  48454. * @param scene defines the scene the texture is attached to
  48455. * @param data defines the array of data to use to create each face
  48456. * @param size defines the size of the textures
  48457. * @param format defines the format of the data
  48458. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  48459. * @param generateMipMaps defines if the engine should generate the mip levels
  48460. * @param invertY defines if data must be stored with Y axis inverted
  48461. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  48462. * @param compression defines the compression used (null by default)
  48463. */
  48464. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  48465. /**
  48466. * Updates the raw cube texture.
  48467. * @param data defines the data to store
  48468. * @param format defines the data format
  48469. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  48470. * @param invertY defines if data must be stored with Y axis inverted
  48471. * @param compression defines the compression used (null by default)
  48472. * @param level defines which level of the texture to update
  48473. */
  48474. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  48475. /**
  48476. * Updates a raw cube texture with RGBD encoded data.
  48477. * @param data defines the array of data [mipmap][face] to use to create each face
  48478. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  48479. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48480. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48481. * @returns a promsie that resolves when the operation is complete
  48482. */
  48483. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  48484. /**
  48485. * Clones the raw cube texture.
  48486. * @return a new cube texture
  48487. */
  48488. clone(): CubeTexture;
  48489. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48490. }
  48491. }
  48492. declare module BABYLON {
  48493. /**
  48494. * Class used to store 3D textures containing user data
  48495. */
  48496. export class RawTexture3D extends Texture {
  48497. /** Gets or sets the texture format to use */
  48498. format: number;
  48499. private _engine;
  48500. /**
  48501. * Create a new RawTexture3D
  48502. * @param data defines the data of the texture
  48503. * @param width defines the width of the texture
  48504. * @param height defines the height of the texture
  48505. * @param depth defines the depth of the texture
  48506. * @param format defines the texture format to use
  48507. * @param scene defines the hosting scene
  48508. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  48509. * @param invertY defines if texture must be stored with Y axis inverted
  48510. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  48511. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  48512. */
  48513. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  48514. /** Gets or sets the texture format to use */
  48515. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  48516. /**
  48517. * Update the texture with new data
  48518. * @param data defines the data to store in the texture
  48519. */
  48520. update(data: ArrayBufferView): void;
  48521. }
  48522. }
  48523. declare module BABYLON {
  48524. /**
  48525. * Creates a refraction texture used by refraction channel of the standard material.
  48526. * It is like a mirror but to see through a material.
  48527. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48528. */
  48529. export class RefractionTexture extends RenderTargetTexture {
  48530. /**
  48531. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  48532. * 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.
  48533. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48534. */
  48535. refractionPlane: Plane;
  48536. /**
  48537. * Define how deep under the surface we should see.
  48538. */
  48539. depth: number;
  48540. /**
  48541. * Creates a refraction texture used by refraction channel of the standard material.
  48542. * It is like a mirror but to see through a material.
  48543. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48544. * @param name Define the texture name
  48545. * @param size Define the size of the underlying texture
  48546. * @param scene Define the scene the refraction belongs to
  48547. * @param generateMipMaps Define if we need to generate mips level for the refraction
  48548. */
  48549. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  48550. /**
  48551. * Clone the refraction texture.
  48552. * @returns the cloned texture
  48553. */
  48554. clone(): RefractionTexture;
  48555. /**
  48556. * Serialize the texture to a JSON representation you could use in Parse later on
  48557. * @returns the serialized JSON representation
  48558. */
  48559. serialize(): any;
  48560. }
  48561. }
  48562. declare module BABYLON {
  48563. /**
  48564. * Helper class to push actions to a pool of workers.
  48565. */
  48566. export class WorkerPool implements IDisposable {
  48567. private _workerInfos;
  48568. private _pendingActions;
  48569. /**
  48570. * Constructor
  48571. * @param workers Array of workers to use for actions
  48572. */
  48573. constructor(workers: Array<Worker>);
  48574. /**
  48575. * Terminates all workers and clears any pending actions.
  48576. */
  48577. dispose(): void;
  48578. /**
  48579. * Pushes an action to the worker pool. If all the workers are active, the action will be
  48580. * pended until a worker has completed its action.
  48581. * @param action The action to perform. Call onComplete when the action is complete.
  48582. */
  48583. push(action: (worker: Worker, onComplete: () => void) => void): void;
  48584. private _execute;
  48585. }
  48586. }
  48587. declare module BABYLON {
  48588. /**
  48589. * Configuration for Draco compression
  48590. */
  48591. export interface IDracoCompressionConfiguration {
  48592. /**
  48593. * Configuration for the decoder.
  48594. */
  48595. decoder?: {
  48596. /**
  48597. * The url to the WebAssembly module.
  48598. */
  48599. wasmUrl?: string;
  48600. /**
  48601. * The url to the WebAssembly binary.
  48602. */
  48603. wasmBinaryUrl?: string;
  48604. /**
  48605. * The url to the fallback JavaScript module.
  48606. */
  48607. fallbackUrl?: string;
  48608. };
  48609. }
  48610. /**
  48611. * Draco compression (https://google.github.io/draco/)
  48612. *
  48613. * This class wraps the Draco module.
  48614. *
  48615. * **Encoder**
  48616. *
  48617. * The encoder is not currently implemented.
  48618. *
  48619. * **Decoder**
  48620. *
  48621. * 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.
  48622. *
  48623. * To update the configuration, use the following code:
  48624. * ```javascript
  48625. * DracoCompression.Configuration = {
  48626. * decoder: {
  48627. * wasmUrl: "<url to the WebAssembly library>",
  48628. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48629. * fallbackUrl: "<url to the fallback JavaScript library>",
  48630. * }
  48631. * };
  48632. * ```
  48633. *
  48634. * 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.
  48635. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48636. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48637. *
  48638. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48639. * ```javascript
  48640. * var dracoCompression = new DracoCompression();
  48641. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48642. * [VertexBuffer.PositionKind]: 0
  48643. * });
  48644. * ```
  48645. *
  48646. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48647. */
  48648. export class DracoCompression implements IDisposable {
  48649. private _workerPoolPromise;
  48650. /**
  48651. * The configuration. Defaults to the following urls:
  48652. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48653. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48654. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48655. */
  48656. static Configuration: IDracoCompressionConfiguration;
  48657. /**
  48658. * Returns true if the decoder is available.
  48659. */
  48660. static readonly DecoderAvailable: boolean;
  48661. /**
  48662. * Default number of workers to create when creating the draco compression object.
  48663. */
  48664. static DefaultNumWorkers: number;
  48665. private static GetDefaultNumWorkers;
  48666. /**
  48667. * Constructor
  48668. * @param numWorkers The number of workers for async operations
  48669. */
  48670. constructor(numWorkers?: number);
  48671. /**
  48672. * Stop all async operations and release resources.
  48673. */
  48674. dispose(): void;
  48675. /**
  48676. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  48677. * @returns a promise that resolves when ready
  48678. */
  48679. whenReadyAsync(): Promise<void>;
  48680. /**
  48681. * Decode Draco compressed mesh data to vertex data.
  48682. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  48683. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  48684. * @returns A promise that resolves with the decoded vertex data
  48685. */
  48686. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  48687. [kind: string]: number;
  48688. }): Promise<VertexData>;
  48689. /**
  48690. * The worker function that gets converted to a blob url to pass into a worker.
  48691. */
  48692. private static _Worker;
  48693. private _loadDecoderWasmBinaryAsync;
  48694. }
  48695. }
  48696. declare module BABYLON {
  48697. /**
  48698. * Class for building Constructive Solid Geometry
  48699. */
  48700. export class CSG {
  48701. private polygons;
  48702. /**
  48703. * The world matrix
  48704. */
  48705. matrix: Matrix;
  48706. /**
  48707. * Stores the position
  48708. */
  48709. position: Vector3;
  48710. /**
  48711. * Stores the rotation
  48712. */
  48713. rotation: Vector3;
  48714. /**
  48715. * Stores the rotation quaternion
  48716. */
  48717. rotationQuaternion: Nullable<Quaternion>;
  48718. /**
  48719. * Stores the scaling vector
  48720. */
  48721. scaling: Vector3;
  48722. /**
  48723. * Convert the Mesh to CSG
  48724. * @param mesh The Mesh to convert to CSG
  48725. * @returns A new CSG from the Mesh
  48726. */
  48727. static FromMesh(mesh: Mesh): CSG;
  48728. /**
  48729. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  48730. * @param polygons Polygons used to construct a CSG solid
  48731. */
  48732. private static FromPolygons;
  48733. /**
  48734. * Clones, or makes a deep copy, of the CSG
  48735. * @returns A new CSG
  48736. */
  48737. clone(): CSG;
  48738. /**
  48739. * Unions this CSG with another CSG
  48740. * @param csg The CSG to union against this CSG
  48741. * @returns The unioned CSG
  48742. */
  48743. union(csg: CSG): CSG;
  48744. /**
  48745. * Unions this CSG with another CSG in place
  48746. * @param csg The CSG to union against this CSG
  48747. */
  48748. unionInPlace(csg: CSG): void;
  48749. /**
  48750. * Subtracts this CSG with another CSG
  48751. * @param csg The CSG to subtract against this CSG
  48752. * @returns A new CSG
  48753. */
  48754. subtract(csg: CSG): CSG;
  48755. /**
  48756. * Subtracts this CSG with another CSG in place
  48757. * @param csg The CSG to subtact against this CSG
  48758. */
  48759. subtractInPlace(csg: CSG): void;
  48760. /**
  48761. * Intersect this CSG with another CSG
  48762. * @param csg The CSG to intersect against this CSG
  48763. * @returns A new CSG
  48764. */
  48765. intersect(csg: CSG): CSG;
  48766. /**
  48767. * Intersects this CSG with another CSG in place
  48768. * @param csg The CSG to intersect against this CSG
  48769. */
  48770. intersectInPlace(csg: CSG): void;
  48771. /**
  48772. * Return a new CSG solid with solid and empty space switched. This solid is
  48773. * not modified.
  48774. * @returns A new CSG solid with solid and empty space switched
  48775. */
  48776. inverse(): CSG;
  48777. /**
  48778. * Inverses the CSG in place
  48779. */
  48780. inverseInPlace(): void;
  48781. /**
  48782. * This is used to keep meshes transformations so they can be restored
  48783. * when we build back a Babylon Mesh
  48784. * NB : All CSG operations are performed in world coordinates
  48785. * @param csg The CSG to copy the transform attributes from
  48786. * @returns This CSG
  48787. */
  48788. copyTransformAttributes(csg: CSG): CSG;
  48789. /**
  48790. * Build Raw mesh from CSG
  48791. * Coordinates here are in world space
  48792. * @param name The name of the mesh geometry
  48793. * @param scene The Scene
  48794. * @param keepSubMeshes Specifies if the submeshes should be kept
  48795. * @returns A new Mesh
  48796. */
  48797. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  48798. /**
  48799. * Build Mesh from CSG taking material and transforms into account
  48800. * @param name The name of the Mesh
  48801. * @param material The material of the Mesh
  48802. * @param scene The Scene
  48803. * @param keepSubMeshes Specifies if submeshes should be kept
  48804. * @returns The new Mesh
  48805. */
  48806. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  48807. }
  48808. }
  48809. declare module BABYLON {
  48810. /**
  48811. * Class used to create a trail following a mesh
  48812. */
  48813. export class TrailMesh extends Mesh {
  48814. private _generator;
  48815. private _autoStart;
  48816. private _running;
  48817. private _diameter;
  48818. private _length;
  48819. private _sectionPolygonPointsCount;
  48820. private _sectionVectors;
  48821. private _sectionNormalVectors;
  48822. private _beforeRenderObserver;
  48823. /**
  48824. * @constructor
  48825. * @param name The value used by scene.getMeshByName() to do a lookup.
  48826. * @param generator The mesh to generate a trail.
  48827. * @param scene The scene to add this mesh to.
  48828. * @param diameter Diameter of trailing mesh. Default is 1.
  48829. * @param length Length of trailing mesh. Default is 60.
  48830. * @param autoStart Automatically start trailing mesh. Default true.
  48831. */
  48832. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  48833. /**
  48834. * "TrailMesh"
  48835. * @returns "TrailMesh"
  48836. */
  48837. getClassName(): string;
  48838. private _createMesh;
  48839. /**
  48840. * Start trailing mesh.
  48841. */
  48842. start(): void;
  48843. /**
  48844. * Stop trailing mesh.
  48845. */
  48846. stop(): void;
  48847. /**
  48848. * Update trailing mesh geometry.
  48849. */
  48850. update(): void;
  48851. /**
  48852. * Returns a new TrailMesh object.
  48853. * @param name is a string, the name given to the new mesh
  48854. * @param newGenerator use new generator object for cloned trail mesh
  48855. * @returns a new mesh
  48856. */
  48857. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  48858. /**
  48859. * Serializes this trail mesh
  48860. * @param serializationObject object to write serialization to
  48861. */
  48862. serialize(serializationObject: any): void;
  48863. /**
  48864. * Parses a serialized trail mesh
  48865. * @param parsedMesh the serialized mesh
  48866. * @param scene the scene to create the trail mesh in
  48867. * @returns the created trail mesh
  48868. */
  48869. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  48870. }
  48871. }
  48872. declare module BABYLON {
  48873. /**
  48874. * Class containing static functions to help procedurally build meshes
  48875. */
  48876. export class TorusKnotBuilder {
  48877. /**
  48878. * Creates a torus knot mesh
  48879. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  48880. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  48881. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  48882. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  48883. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48884. * * If you create a double-sided mesh, you can choose what parts of 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
  48885. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48886. * @param name defines the name of the mesh
  48887. * @param options defines the options used to create the mesh
  48888. * @param scene defines the hosting scene
  48889. * @returns the torus knot mesh
  48890. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  48891. */
  48892. static CreateTorusKnot(name: string, options: {
  48893. radius?: number;
  48894. tube?: number;
  48895. radialSegments?: number;
  48896. tubularSegments?: number;
  48897. p?: number;
  48898. q?: number;
  48899. updatable?: boolean;
  48900. sideOrientation?: number;
  48901. frontUVs?: Vector4;
  48902. backUVs?: Vector4;
  48903. }, scene: any): Mesh;
  48904. }
  48905. }
  48906. declare module BABYLON {
  48907. /**
  48908. * Polygon
  48909. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  48910. */
  48911. export class Polygon {
  48912. /**
  48913. * Creates a rectangle
  48914. * @param xmin bottom X coord
  48915. * @param ymin bottom Y coord
  48916. * @param xmax top X coord
  48917. * @param ymax top Y coord
  48918. * @returns points that make the resulting rectation
  48919. */
  48920. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  48921. /**
  48922. * Creates a circle
  48923. * @param radius radius of circle
  48924. * @param cx scale in x
  48925. * @param cy scale in y
  48926. * @param numberOfSides number of sides that make up the circle
  48927. * @returns points that make the resulting circle
  48928. */
  48929. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  48930. /**
  48931. * Creates a polygon from input string
  48932. * @param input Input polygon data
  48933. * @returns the parsed points
  48934. */
  48935. static Parse(input: string): Vector2[];
  48936. /**
  48937. * Starts building a polygon from x and y coordinates
  48938. * @param x x coordinate
  48939. * @param y y coordinate
  48940. * @returns the started path2
  48941. */
  48942. static StartingAt(x: number, y: number): Path2;
  48943. }
  48944. /**
  48945. * Builds a polygon
  48946. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  48947. */
  48948. export class PolygonMeshBuilder {
  48949. private _points;
  48950. private _outlinepoints;
  48951. private _holes;
  48952. private _name;
  48953. private _scene;
  48954. private _epoints;
  48955. private _eholes;
  48956. private _addToepoint;
  48957. /**
  48958. * Babylon reference to the earcut plugin.
  48959. */
  48960. bjsEarcut: any;
  48961. /**
  48962. * Creates a PolygonMeshBuilder
  48963. * @param name name of the builder
  48964. * @param contours Path of the polygon
  48965. * @param scene scene to add to when creating the mesh
  48966. * @param earcutInjection can be used to inject your own earcut reference
  48967. */
  48968. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  48969. /**
  48970. * Adds a whole within the polygon
  48971. * @param hole Array of points defining the hole
  48972. * @returns this
  48973. */
  48974. addHole(hole: Vector2[]): PolygonMeshBuilder;
  48975. /**
  48976. * Creates the polygon
  48977. * @param updatable If the mesh should be updatable
  48978. * @param depth The depth of the mesh created
  48979. * @returns the created mesh
  48980. */
  48981. build(updatable?: boolean, depth?: number): Mesh;
  48982. /**
  48983. * Creates the polygon
  48984. * @param depth The depth of the mesh created
  48985. * @returns the created VertexData
  48986. */
  48987. buildVertexData(depth?: number): VertexData;
  48988. /**
  48989. * Adds a side to the polygon
  48990. * @param positions points that make the polygon
  48991. * @param normals normals of the polygon
  48992. * @param uvs uvs of the polygon
  48993. * @param indices indices of the polygon
  48994. * @param bounds bounds of the polygon
  48995. * @param points points of the polygon
  48996. * @param depth depth of the polygon
  48997. * @param flip flip of the polygon
  48998. */
  48999. private addSide;
  49000. }
  49001. }
  49002. declare module BABYLON {
  49003. /**
  49004. * Class containing static functions to help procedurally build meshes
  49005. */
  49006. export class PolygonBuilder {
  49007. /**
  49008. * Creates a polygon mesh
  49009. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49010. * * 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
  49011. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49013. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  49014. * * Remember you can only change the shape positions, not their number when updating a polygon
  49015. * @param name defines the name of the mesh
  49016. * @param options defines the options used to create the mesh
  49017. * @param scene defines the hosting scene
  49018. * @param earcutInjection can be used to inject your own earcut reference
  49019. * @returns the polygon mesh
  49020. */
  49021. static CreatePolygon(name: string, options: {
  49022. shape: Vector3[];
  49023. holes?: Vector3[][];
  49024. depth?: number;
  49025. faceUV?: Vector4[];
  49026. faceColors?: Color4[];
  49027. updatable?: boolean;
  49028. sideOrientation?: number;
  49029. frontUVs?: Vector4;
  49030. backUVs?: Vector4;
  49031. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  49032. /**
  49033. * Creates an extruded polygon mesh, with depth in the Y direction.
  49034. * * 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)
  49035. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49036. * @param name defines the name of the mesh
  49037. * @param options defines the options used to create the mesh
  49038. * @param scene defines the hosting scene
  49039. * @param earcutInjection can be used to inject your own earcut reference
  49040. * @returns the polygon mesh
  49041. */
  49042. static ExtrudePolygon(name: string, options: {
  49043. shape: Vector3[];
  49044. holes?: Vector3[][];
  49045. depth?: number;
  49046. faceUV?: Vector4[];
  49047. faceColors?: Color4[];
  49048. updatable?: boolean;
  49049. sideOrientation?: number;
  49050. frontUVs?: Vector4;
  49051. backUVs?: Vector4;
  49052. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  49053. }
  49054. }
  49055. declare module BABYLON {
  49056. /**
  49057. * Class containing static functions to help procedurally build meshes
  49058. */
  49059. export class LatheBuilder {
  49060. /**
  49061. * Creates lathe mesh.
  49062. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49063. * * 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
  49064. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49065. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49066. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49067. * * 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
  49068. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49069. * * 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
  49070. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49071. * * If you create a double-sided mesh, you can choose what parts of 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
  49072. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49074. * @param name defines the name of the mesh
  49075. * @param options defines the options used to create the mesh
  49076. * @param scene defines the hosting scene
  49077. * @returns the lathe mesh
  49078. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49079. */
  49080. static CreateLathe(name: string, options: {
  49081. shape: Vector3[];
  49082. radius?: number;
  49083. tessellation?: number;
  49084. clip?: number;
  49085. arc?: number;
  49086. closed?: boolean;
  49087. updatable?: boolean;
  49088. sideOrientation?: number;
  49089. frontUVs?: Vector4;
  49090. backUVs?: Vector4;
  49091. cap?: number;
  49092. invertUV?: boolean;
  49093. }, scene?: Nullable<Scene>): Mesh;
  49094. }
  49095. }
  49096. declare module BABYLON {
  49097. /**
  49098. * Class containing static functions to help procedurally build meshes
  49099. */
  49100. export class TubeBuilder {
  49101. /**
  49102. * Creates a tube mesh.
  49103. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49104. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49105. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49106. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49107. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49108. * * 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)
  49109. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49110. * * 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
  49111. * * 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
  49112. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49113. * * If you create a double-sided mesh, you can choose what parts of 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
  49114. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49116. * @param name defines the name of the mesh
  49117. * @param options defines the options used to create the mesh
  49118. * @param scene defines the hosting scene
  49119. * @returns the tube mesh
  49120. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49121. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49122. */
  49123. static CreateTube(name: string, options: {
  49124. path: Vector3[];
  49125. radius?: number;
  49126. tessellation?: number;
  49127. radiusFunction?: {
  49128. (i: number, distance: number): number;
  49129. };
  49130. cap?: number;
  49131. arc?: number;
  49132. updatable?: boolean;
  49133. sideOrientation?: number;
  49134. frontUVs?: Vector4;
  49135. backUVs?: Vector4;
  49136. instance?: Mesh;
  49137. invertUV?: boolean;
  49138. }, scene?: Nullable<Scene>): Mesh;
  49139. }
  49140. }
  49141. declare module BABYLON {
  49142. /**
  49143. * Class containing static functions to help procedurally build meshes
  49144. */
  49145. export class IcoSphereBuilder {
  49146. /**
  49147. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49148. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49149. * * 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`)
  49150. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49151. * * 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
  49152. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49153. * * If you create a double-sided mesh, you can choose what parts of 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
  49154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49155. * @param name defines the name of the mesh
  49156. * @param options defines the options used to create the mesh
  49157. * @param scene defines the hosting scene
  49158. * @returns the icosahedron mesh
  49159. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49160. */
  49161. static CreateIcoSphere(name: string, options: {
  49162. radius?: number;
  49163. radiusX?: number;
  49164. radiusY?: number;
  49165. radiusZ?: number;
  49166. flat?: boolean;
  49167. subdivisions?: number;
  49168. sideOrientation?: number;
  49169. frontUVs?: Vector4;
  49170. backUVs?: Vector4;
  49171. updatable?: boolean;
  49172. }, scene?: Nullable<Scene>): Mesh;
  49173. }
  49174. }
  49175. declare module BABYLON {
  49176. /**
  49177. * Class containing static functions to help procedurally build meshes
  49178. */
  49179. export class DecalBuilder {
  49180. /**
  49181. * Creates a decal mesh.
  49182. * 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
  49183. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  49184. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  49185. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  49186. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  49187. * @param name defines the name of the mesh
  49188. * @param sourceMesh defines the mesh where the decal must be applied
  49189. * @param options defines the options used to create the mesh
  49190. * @param scene defines the hosting scene
  49191. * @returns the decal mesh
  49192. * @see https://doc.babylonjs.com/how_to/decals
  49193. */
  49194. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  49195. position?: Vector3;
  49196. normal?: Vector3;
  49197. size?: Vector3;
  49198. angle?: number;
  49199. }): Mesh;
  49200. }
  49201. }
  49202. declare module BABYLON {
  49203. /**
  49204. * Class containing static functions to help procedurally build meshes
  49205. */
  49206. export class MeshBuilder {
  49207. /**
  49208. * Creates a box mesh
  49209. * * The parameter `size` sets the size (float) of each box side (default 1)
  49210. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49211. * * 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)
  49212. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49213. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49214. * * If you create a double-sided mesh, you can choose what parts of 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
  49215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49216. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49217. * @param name defines the name of the mesh
  49218. * @param options defines the options used to create the mesh
  49219. * @param scene defines the hosting scene
  49220. * @returns the box mesh
  49221. */
  49222. static CreateBox(name: string, options: {
  49223. size?: number;
  49224. width?: number;
  49225. height?: number;
  49226. depth?: number;
  49227. faceUV?: Vector4[];
  49228. faceColors?: Color4[];
  49229. sideOrientation?: number;
  49230. frontUVs?: Vector4;
  49231. backUVs?: Vector4;
  49232. updatable?: boolean;
  49233. }, scene?: Nullable<Scene>): Mesh;
  49234. /**
  49235. * Creates a sphere mesh
  49236. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49237. * * 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`)
  49238. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49239. * * 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
  49240. * * 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)
  49241. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49242. * * If you create a double-sided mesh, you can choose what parts of 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
  49243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49244. * @param name defines the name of the mesh
  49245. * @param options defines the options used to create the mesh
  49246. * @param scene defines the hosting scene
  49247. * @returns the sphere mesh
  49248. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49249. */
  49250. static CreateSphere(name: string, options: {
  49251. segments?: number;
  49252. diameter?: number;
  49253. diameterX?: number;
  49254. diameterY?: number;
  49255. diameterZ?: number;
  49256. arc?: number;
  49257. slice?: number;
  49258. sideOrientation?: number;
  49259. frontUVs?: Vector4;
  49260. backUVs?: Vector4;
  49261. updatable?: boolean;
  49262. }, scene?: Nullable<Scene>): Mesh;
  49263. /**
  49264. * Creates a plane polygonal mesh. By default, this is a disc
  49265. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  49266. * * 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
  49267. * * 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
  49268. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49269. * * If you create a double-sided mesh, you can choose what parts of 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
  49270. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49271. * @param name defines the name of the mesh
  49272. * @param options defines the options used to create the mesh
  49273. * @param scene defines the hosting scene
  49274. * @returns the plane polygonal mesh
  49275. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  49276. */
  49277. static CreateDisc(name: string, options: {
  49278. radius?: number;
  49279. tessellation?: number;
  49280. arc?: number;
  49281. updatable?: boolean;
  49282. sideOrientation?: number;
  49283. frontUVs?: Vector4;
  49284. backUVs?: Vector4;
  49285. }, scene?: Nullable<Scene>): Mesh;
  49286. /**
  49287. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49288. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49289. * * 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`)
  49290. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49291. * * 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
  49292. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49293. * * If you create a double-sided mesh, you can choose what parts of 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
  49294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49295. * @param name defines the name of the mesh
  49296. * @param options defines the options used to create the mesh
  49297. * @param scene defines the hosting scene
  49298. * @returns the icosahedron mesh
  49299. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49300. */
  49301. static CreateIcoSphere(name: string, options: {
  49302. radius?: number;
  49303. radiusX?: number;
  49304. radiusY?: number;
  49305. radiusZ?: number;
  49306. flat?: boolean;
  49307. subdivisions?: number;
  49308. sideOrientation?: number;
  49309. frontUVs?: Vector4;
  49310. backUVs?: Vector4;
  49311. updatable?: boolean;
  49312. }, scene?: Nullable<Scene>): Mesh;
  49313. /**
  49314. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49315. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49316. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49317. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49318. * * 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
  49319. * * 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
  49320. * * 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
  49321. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49322. * * If you create a double-sided mesh, you can choose what parts of 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
  49323. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49324. * * 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
  49325. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49326. * * 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
  49327. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49329. * @param name defines the name of the mesh
  49330. * @param options defines the options used to create the mesh
  49331. * @param scene defines the hosting scene
  49332. * @returns the ribbon mesh
  49333. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49334. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49335. */
  49336. static CreateRibbon(name: string, options: {
  49337. pathArray: Vector3[][];
  49338. closeArray?: boolean;
  49339. closePath?: boolean;
  49340. offset?: number;
  49341. updatable?: boolean;
  49342. sideOrientation?: number;
  49343. frontUVs?: Vector4;
  49344. backUVs?: Vector4;
  49345. instance?: Mesh;
  49346. invertUV?: boolean;
  49347. uvs?: Vector2[];
  49348. colors?: Color4[];
  49349. }, scene?: Nullable<Scene>): Mesh;
  49350. /**
  49351. * Creates a cylinder or a cone mesh
  49352. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  49353. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  49354. * * 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.
  49355. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  49356. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  49357. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  49358. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  49359. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  49360. * * 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).
  49361. * * 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
  49362. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  49363. * * 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
  49364. * * 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.
  49365. * * If `enclose` is false, a ring surface is one element.
  49366. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  49367. * * 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
  49368. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49369. * * If you create a double-sided mesh, you can choose what parts of 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
  49370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49371. * @param name defines the name of the mesh
  49372. * @param options defines the options used to create the mesh
  49373. * @param scene defines the hosting scene
  49374. * @returns the cylinder mesh
  49375. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  49376. */
  49377. static CreateCylinder(name: string, options: {
  49378. height?: number;
  49379. diameterTop?: number;
  49380. diameterBottom?: number;
  49381. diameter?: number;
  49382. tessellation?: number;
  49383. subdivisions?: number;
  49384. arc?: number;
  49385. faceColors?: Color4[];
  49386. faceUV?: Vector4[];
  49387. updatable?: boolean;
  49388. hasRings?: boolean;
  49389. enclose?: boolean;
  49390. sideOrientation?: number;
  49391. frontUVs?: Vector4;
  49392. backUVs?: Vector4;
  49393. }, scene?: Nullable<Scene>): Mesh;
  49394. /**
  49395. * Creates a torus mesh
  49396. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  49397. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  49398. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  49399. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49400. * * If you create a double-sided mesh, you can choose what parts of 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
  49401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49402. * @param name defines the name of the mesh
  49403. * @param options defines the options used to create the mesh
  49404. * @param scene defines the hosting scene
  49405. * @returns the torus mesh
  49406. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  49407. */
  49408. static CreateTorus(name: string, options: {
  49409. diameter?: number;
  49410. thickness?: number;
  49411. tessellation?: number;
  49412. updatable?: boolean;
  49413. sideOrientation?: number;
  49414. frontUVs?: Vector4;
  49415. backUVs?: Vector4;
  49416. }, scene?: Nullable<Scene>): Mesh;
  49417. /**
  49418. * Creates a torus knot mesh
  49419. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49420. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49421. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49422. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49423. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49424. * * If you create a double-sided mesh, you can choose what parts of 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
  49425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49426. * @param name defines the name of the mesh
  49427. * @param options defines the options used to create the mesh
  49428. * @param scene defines the hosting scene
  49429. * @returns the torus knot mesh
  49430. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49431. */
  49432. static CreateTorusKnot(name: string, options: {
  49433. radius?: number;
  49434. tube?: number;
  49435. radialSegments?: number;
  49436. tubularSegments?: number;
  49437. p?: number;
  49438. q?: number;
  49439. updatable?: boolean;
  49440. sideOrientation?: number;
  49441. frontUVs?: Vector4;
  49442. backUVs?: Vector4;
  49443. }, scene?: Nullable<Scene>): Mesh;
  49444. /**
  49445. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49446. * * 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
  49447. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49448. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49449. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49450. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49451. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49452. * * 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
  49453. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49455. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49456. * @param name defines the name of the new line system
  49457. * @param options defines the options used to create the line system
  49458. * @param scene defines the hosting scene
  49459. * @returns a new line system mesh
  49460. */
  49461. static CreateLineSystem(name: string, options: {
  49462. lines: Vector3[][];
  49463. updatable?: boolean;
  49464. instance?: Nullable<LinesMesh>;
  49465. colors?: Nullable<Color4[][]>;
  49466. useVertexAlpha?: boolean;
  49467. }, scene: Nullable<Scene>): LinesMesh;
  49468. /**
  49469. * Creates a line mesh
  49470. * 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
  49471. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49472. * * The parameter `points` is an array successive Vector3
  49473. * * 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
  49474. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49475. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49476. * * When updating an instance, remember that only point positions can change, not the number of points
  49477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49478. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49479. * @param name defines the name of the new line system
  49480. * @param options defines the options used to create the line system
  49481. * @param scene defines the hosting scene
  49482. * @returns a new line mesh
  49483. */
  49484. static CreateLines(name: string, options: {
  49485. points: Vector3[];
  49486. updatable?: boolean;
  49487. instance?: Nullable<LinesMesh>;
  49488. colors?: Color4[];
  49489. useVertexAlpha?: boolean;
  49490. }, scene?: Nullable<Scene>): LinesMesh;
  49491. /**
  49492. * Creates a dashed line mesh
  49493. * * 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
  49494. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49495. * * The parameter `points` is an array successive Vector3
  49496. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49497. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49498. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49499. * * 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
  49500. * * When updating an instance, remember that only point positions can change, not the number of points
  49501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49502. * @param name defines the name of the mesh
  49503. * @param options defines the options used to create the mesh
  49504. * @param scene defines the hosting scene
  49505. * @returns the dashed line mesh
  49506. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49507. */
  49508. static CreateDashedLines(name: string, options: {
  49509. points: Vector3[];
  49510. dashSize?: number;
  49511. gapSize?: number;
  49512. dashNb?: number;
  49513. updatable?: boolean;
  49514. instance?: LinesMesh;
  49515. }, scene?: Nullable<Scene>): LinesMesh;
  49516. /**
  49517. * 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.
  49518. * * 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.
  49519. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49520. * * 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.
  49521. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49522. * * 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
  49523. * * 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
  49524. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49525. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49526. * * If you create a double-sided mesh, you can choose what parts of 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
  49527. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49528. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49529. * @param name defines the name of the mesh
  49530. * @param options defines the options used to create the mesh
  49531. * @param scene defines the hosting scene
  49532. * @returns the extruded shape mesh
  49533. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49534. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49535. */
  49536. static ExtrudeShape(name: string, options: {
  49537. shape: Vector3[];
  49538. path: Vector3[];
  49539. scale?: number;
  49540. rotation?: number;
  49541. cap?: number;
  49542. updatable?: boolean;
  49543. sideOrientation?: number;
  49544. frontUVs?: Vector4;
  49545. backUVs?: Vector4;
  49546. instance?: Mesh;
  49547. invertUV?: boolean;
  49548. }, scene?: Nullable<Scene>): Mesh;
  49549. /**
  49550. * Creates an custom extruded shape mesh.
  49551. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49552. * * 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.
  49553. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49554. * * 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
  49555. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49556. * * 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
  49557. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49558. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49559. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49560. * * 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
  49561. * * 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
  49562. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49563. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49564. * * If you create a double-sided mesh, you can choose what parts of 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
  49565. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49567. * @param name defines the name of the mesh
  49568. * @param options defines the options used to create the mesh
  49569. * @param scene defines the hosting scene
  49570. * @returns the custom extruded shape mesh
  49571. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49572. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49573. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49574. */
  49575. static ExtrudeShapeCustom(name: string, options: {
  49576. shape: Vector3[];
  49577. path: Vector3[];
  49578. scaleFunction?: any;
  49579. rotationFunction?: any;
  49580. ribbonCloseArray?: boolean;
  49581. ribbonClosePath?: boolean;
  49582. cap?: number;
  49583. updatable?: boolean;
  49584. sideOrientation?: number;
  49585. frontUVs?: Vector4;
  49586. backUVs?: Vector4;
  49587. instance?: Mesh;
  49588. invertUV?: boolean;
  49589. }, scene?: Nullable<Scene>): Mesh;
  49590. /**
  49591. * Creates lathe mesh.
  49592. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49593. * * 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
  49594. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49595. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49596. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49597. * * 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
  49598. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49599. * * 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
  49600. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49601. * * If you create a double-sided mesh, you can choose what parts of 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
  49602. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  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. * @param name defines the name of the mesh
  49605. * @param options defines the options used to create the mesh
  49606. * @param scene defines the hosting scene
  49607. * @returns the lathe mesh
  49608. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49609. */
  49610. static CreateLathe(name: string, options: {
  49611. shape: Vector3[];
  49612. radius?: number;
  49613. tessellation?: number;
  49614. clip?: number;
  49615. arc?: number;
  49616. closed?: boolean;
  49617. updatable?: boolean;
  49618. sideOrientation?: number;
  49619. frontUVs?: Vector4;
  49620. backUVs?: Vector4;
  49621. cap?: number;
  49622. invertUV?: boolean;
  49623. }, scene?: Nullable<Scene>): Mesh;
  49624. /**
  49625. * Creates a plane mesh
  49626. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  49627. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  49628. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  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 plane mesh
  49636. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  49637. */
  49638. static CreatePlane(name: string, options: {
  49639. size?: number;
  49640. width?: number;
  49641. height?: number;
  49642. sideOrientation?: number;
  49643. frontUVs?: Vector4;
  49644. backUVs?: Vector4;
  49645. updatable?: boolean;
  49646. sourcePlane?: Plane;
  49647. }, scene?: Nullable<Scene>): Mesh;
  49648. /**
  49649. * Creates a ground mesh
  49650. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  49651. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  49652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49653. * @param name defines the name of the mesh
  49654. * @param options defines the options used to create the mesh
  49655. * @param scene defines the hosting scene
  49656. * @returns the ground mesh
  49657. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  49658. */
  49659. static CreateGround(name: string, options: {
  49660. width?: number;
  49661. height?: number;
  49662. subdivisions?: number;
  49663. subdivisionsX?: number;
  49664. subdivisionsY?: number;
  49665. updatable?: boolean;
  49666. }, scene?: Nullable<Scene>): Mesh;
  49667. /**
  49668. * Creates a tiled ground mesh
  49669. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  49670. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  49671. * * 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
  49672. * * 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
  49673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49674. * @param name defines the name of the mesh
  49675. * @param options defines the options used to create the mesh
  49676. * @param scene defines the hosting scene
  49677. * @returns the tiled ground mesh
  49678. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  49679. */
  49680. static CreateTiledGround(name: string, options: {
  49681. xmin: number;
  49682. zmin: number;
  49683. xmax: number;
  49684. zmax: number;
  49685. subdivisions?: {
  49686. w: number;
  49687. h: number;
  49688. };
  49689. precision?: {
  49690. w: number;
  49691. h: number;
  49692. };
  49693. updatable?: boolean;
  49694. }, scene?: Nullable<Scene>): Mesh;
  49695. /**
  49696. * Creates a ground mesh from a height map
  49697. * * The parameter `url` sets the URL of the height map image resource.
  49698. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  49699. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  49700. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  49701. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  49702. * * 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.
  49703. * * 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).
  49704. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  49705. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49706. * @param name defines the name of the mesh
  49707. * @param url defines the url to the height map
  49708. * @param options defines the options used to create the mesh
  49709. * @param scene defines the hosting scene
  49710. * @returns the ground mesh
  49711. * @see https://doc.babylonjs.com/babylon101/height_map
  49712. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  49713. */
  49714. static CreateGroundFromHeightMap(name: string, url: string, options: {
  49715. width?: number;
  49716. height?: number;
  49717. subdivisions?: number;
  49718. minHeight?: number;
  49719. maxHeight?: number;
  49720. colorFilter?: Color3;
  49721. alphaFilter?: number;
  49722. updatable?: boolean;
  49723. onReady?: (mesh: GroundMesh) => void;
  49724. }, scene?: Nullable<Scene>): GroundMesh;
  49725. /**
  49726. * Creates a polygon mesh
  49727. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49728. * * 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
  49729. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49730. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49731. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  49732. * * Remember you can only change the shape positions, not their number when updating a polygon
  49733. * @param name defines the name of the mesh
  49734. * @param options defines the options used to create the mesh
  49735. * @param scene defines the hosting scene
  49736. * @param earcutInjection can be used to inject your own earcut reference
  49737. * @returns the polygon mesh
  49738. */
  49739. static CreatePolygon(name: string, options: {
  49740. shape: Vector3[];
  49741. holes?: Vector3[][];
  49742. depth?: number;
  49743. faceUV?: Vector4[];
  49744. faceColors?: Color4[];
  49745. updatable?: boolean;
  49746. sideOrientation?: number;
  49747. frontUVs?: Vector4;
  49748. backUVs?: Vector4;
  49749. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  49750. /**
  49751. * Creates an extruded polygon mesh, with depth in the Y direction.
  49752. * * 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)
  49753. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49754. * @param name defines the name of the mesh
  49755. * @param options defines the options used to create the mesh
  49756. * @param scene defines the hosting scene
  49757. * @param earcutInjection can be used to inject your own earcut reference
  49758. * @returns the polygon mesh
  49759. */
  49760. static ExtrudePolygon(name: string, options: {
  49761. shape: Vector3[];
  49762. holes?: Vector3[][];
  49763. depth?: number;
  49764. faceUV?: Vector4[];
  49765. faceColors?: Color4[];
  49766. updatable?: boolean;
  49767. sideOrientation?: number;
  49768. frontUVs?: Vector4;
  49769. backUVs?: Vector4;
  49770. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  49771. /**
  49772. * Creates a tube mesh.
  49773. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49774. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49775. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49776. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49777. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49778. * * 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)
  49779. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49780. * * 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
  49781. * * 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
  49782. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49783. * * If you create a double-sided mesh, you can choose what parts of 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
  49784. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49786. * @param name defines the name of the mesh
  49787. * @param options defines the options used to create the mesh
  49788. * @param scene defines the hosting scene
  49789. * @returns the tube mesh
  49790. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49791. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49792. */
  49793. static CreateTube(name: string, options: {
  49794. path: Vector3[];
  49795. radius?: number;
  49796. tessellation?: number;
  49797. radiusFunction?: {
  49798. (i: number, distance: number): number;
  49799. };
  49800. cap?: number;
  49801. arc?: number;
  49802. updatable?: boolean;
  49803. sideOrientation?: number;
  49804. frontUVs?: Vector4;
  49805. backUVs?: Vector4;
  49806. instance?: Mesh;
  49807. invertUV?: boolean;
  49808. }, scene?: Nullable<Scene>): Mesh;
  49809. /**
  49810. * Creates a polyhedron mesh
  49811. * * 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
  49812. * * The parameter `size` (positive float, default 1) sets the polygon size
  49813. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  49814. * * 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`
  49815. * * 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
  49816. * * 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)`)
  49817. * * 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
  49818. * * 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
  49819. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49820. * * If you create a double-sided mesh, you can choose what parts of 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
  49821. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49822. * @param name defines the name of the mesh
  49823. * @param options defines the options used to create the mesh
  49824. * @param scene defines the hosting scene
  49825. * @returns the polyhedron mesh
  49826. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  49827. */
  49828. static CreatePolyhedron(name: string, options: {
  49829. type?: number;
  49830. size?: number;
  49831. sizeX?: number;
  49832. sizeY?: number;
  49833. sizeZ?: number;
  49834. custom?: any;
  49835. faceUV?: Vector4[];
  49836. faceColors?: Color4[];
  49837. flat?: boolean;
  49838. updatable?: boolean;
  49839. sideOrientation?: number;
  49840. frontUVs?: Vector4;
  49841. backUVs?: Vector4;
  49842. }, scene?: Nullable<Scene>): Mesh;
  49843. /**
  49844. * Creates a decal mesh.
  49845. * 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
  49846. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  49847. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  49848. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  49849. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  49850. * @param name defines the name of the mesh
  49851. * @param sourceMesh defines the mesh where the decal must be applied
  49852. * @param options defines the options used to create the mesh
  49853. * @param scene defines the hosting scene
  49854. * @returns the decal mesh
  49855. * @see https://doc.babylonjs.com/how_to/decals
  49856. */
  49857. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  49858. position?: Vector3;
  49859. normal?: Vector3;
  49860. size?: Vector3;
  49861. angle?: number;
  49862. }): Mesh;
  49863. }
  49864. }
  49865. declare module BABYLON {
  49866. /**
  49867. * A simplifier interface for future simplification implementations
  49868. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49869. */
  49870. export interface ISimplifier {
  49871. /**
  49872. * Simplification of a given mesh according to the given settings.
  49873. * Since this requires computation, it is assumed that the function runs async.
  49874. * @param settings The settings of the simplification, including quality and distance
  49875. * @param successCallback A callback that will be called after the mesh was simplified.
  49876. * @param errorCallback in case of an error, this callback will be called. optional.
  49877. */
  49878. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  49879. }
  49880. /**
  49881. * Expected simplification settings.
  49882. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  49883. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49884. */
  49885. export interface ISimplificationSettings {
  49886. /**
  49887. * Gets or sets the expected quality
  49888. */
  49889. quality: number;
  49890. /**
  49891. * Gets or sets the distance when this optimized version should be used
  49892. */
  49893. distance: number;
  49894. /**
  49895. * Gets an already optimized mesh
  49896. */
  49897. optimizeMesh?: boolean;
  49898. }
  49899. /**
  49900. * Class used to specify simplification options
  49901. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49902. */
  49903. export class SimplificationSettings implements ISimplificationSettings {
  49904. /** expected quality */
  49905. quality: number;
  49906. /** distance when this optimized version should be used */
  49907. distance: number;
  49908. /** already optimized mesh */
  49909. optimizeMesh?: boolean | undefined;
  49910. /**
  49911. * Creates a SimplificationSettings
  49912. * @param quality expected quality
  49913. * @param distance distance when this optimized version should be used
  49914. * @param optimizeMesh already optimized mesh
  49915. */
  49916. constructor(
  49917. /** expected quality */
  49918. quality: number,
  49919. /** distance when this optimized version should be used */
  49920. distance: number,
  49921. /** already optimized mesh */
  49922. optimizeMesh?: boolean | undefined);
  49923. }
  49924. /**
  49925. * Interface used to define a simplification task
  49926. */
  49927. export interface ISimplificationTask {
  49928. /**
  49929. * Array of settings
  49930. */
  49931. settings: Array<ISimplificationSettings>;
  49932. /**
  49933. * Simplification type
  49934. */
  49935. simplificationType: SimplificationType;
  49936. /**
  49937. * Mesh to simplify
  49938. */
  49939. mesh: Mesh;
  49940. /**
  49941. * Callback called on success
  49942. */
  49943. successCallback?: () => void;
  49944. /**
  49945. * Defines if parallel processing can be used
  49946. */
  49947. parallelProcessing: boolean;
  49948. }
  49949. /**
  49950. * Queue used to order the simplification tasks
  49951. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49952. */
  49953. export class SimplificationQueue {
  49954. private _simplificationArray;
  49955. /**
  49956. * Gets a boolean indicating that the process is still running
  49957. */
  49958. running: boolean;
  49959. /**
  49960. * Creates a new queue
  49961. */
  49962. constructor();
  49963. /**
  49964. * Adds a new simplification task
  49965. * @param task defines a task to add
  49966. */
  49967. addTask(task: ISimplificationTask): void;
  49968. /**
  49969. * Execute next task
  49970. */
  49971. executeNext(): void;
  49972. /**
  49973. * Execute a simplification task
  49974. * @param task defines the task to run
  49975. */
  49976. runSimplification(task: ISimplificationTask): void;
  49977. private getSimplifier;
  49978. }
  49979. /**
  49980. * The implemented types of simplification
  49981. * At the moment only Quadratic Error Decimation is implemented
  49982. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49983. */
  49984. export enum SimplificationType {
  49985. /** Quadratic error decimation */
  49986. QUADRATIC = 0
  49987. }
  49988. }
  49989. declare module BABYLON {
  49990. interface Scene {
  49991. /** @hidden (Backing field) */ simplificationQueue: SimplificationQueue;
  49992. /**
  49993. * Gets or sets the simplification queue attached to the scene
  49994. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49995. */
  49996. simplificationQueue: SimplificationQueue;
  49997. }
  49998. interface Mesh {
  49999. /**
  50000. * Simplify the mesh according to the given array of settings.
  50001. * Function will return immediately and will simplify async
  50002. * @param settings a collection of simplification settings
  50003. * @param parallelProcessing should all levels calculate parallel or one after the other
  50004. * @param simplificationType the type of simplification to run
  50005. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  50006. * @returns the current mesh
  50007. */
  50008. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  50009. }
  50010. /**
  50011. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  50012. * created in a scene
  50013. */
  50014. export class SimplicationQueueSceneComponent implements ISceneComponent {
  50015. /**
  50016. * The component name helpfull to identify the component in the list of scene components.
  50017. */
  50018. readonly name: string;
  50019. /**
  50020. * The scene the component belongs to.
  50021. */
  50022. scene: Scene;
  50023. /**
  50024. * Creates a new instance of the component for the given scene
  50025. * @param scene Defines the scene to register the component in
  50026. */
  50027. constructor(scene: Scene);
  50028. /**
  50029. * Registers the component in a given scene
  50030. */
  50031. register(): void;
  50032. /**
  50033. * Rebuilds the elements related to this component in case of
  50034. * context lost for instance.
  50035. */
  50036. rebuild(): void;
  50037. /**
  50038. * Disposes the component and the associated ressources
  50039. */
  50040. dispose(): void;
  50041. private _beforeCameraUpdate;
  50042. }
  50043. }
  50044. declare module BABYLON {
  50045. /**
  50046. * Class used to enable access to IndexedDB
  50047. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  50048. */
  50049. export class Database implements IOfflineProvider {
  50050. private _callbackManifestChecked;
  50051. private _currentSceneUrl;
  50052. private _db;
  50053. private _enableSceneOffline;
  50054. private _enableTexturesOffline;
  50055. private _manifestVersionFound;
  50056. private _mustUpdateRessources;
  50057. private _hasReachedQuota;
  50058. private _isSupported;
  50059. private _idbFactory;
  50060. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  50061. private static IsUASupportingBlobStorage;
  50062. /**
  50063. * Gets a boolean indicating if Database storate is enabled (off by default)
  50064. */
  50065. static IDBStorageEnabled: boolean;
  50066. /**
  50067. * Gets a boolean indicating if scene must be saved in the database
  50068. */
  50069. readonly enableSceneOffline: boolean;
  50070. /**
  50071. * Gets a boolean indicating if textures must be saved in the database
  50072. */
  50073. readonly enableTexturesOffline: boolean;
  50074. /**
  50075. * Creates a new Database
  50076. * @param urlToScene defines the url to load the scene
  50077. * @param callbackManifestChecked defines the callback to use when manifest is checked
  50078. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  50079. */
  50080. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  50081. private static _ParseURL;
  50082. private static _ReturnFullUrlLocation;
  50083. private _checkManifestFile;
  50084. /**
  50085. * Open the database and make it available
  50086. * @param successCallback defines the callback to call on success
  50087. * @param errorCallback defines the callback to call on error
  50088. */
  50089. open(successCallback: () => void, errorCallback: () => void): void;
  50090. /**
  50091. * Loads an image from the database
  50092. * @param url defines the url to load from
  50093. * @param image defines the target DOM image
  50094. */
  50095. loadImage(url: string, image: HTMLImageElement): void;
  50096. private _loadImageFromDBAsync;
  50097. private _saveImageIntoDBAsync;
  50098. private _checkVersionFromDB;
  50099. private _loadVersionFromDBAsync;
  50100. private _saveVersionIntoDBAsync;
  50101. /**
  50102. * Loads a file from database
  50103. * @param url defines the URL to load from
  50104. * @param sceneLoaded defines a callback to call on success
  50105. * @param progressCallBack defines a callback to call when progress changed
  50106. * @param errorCallback defines a callback to call on error
  50107. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  50108. */
  50109. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  50110. private _loadFileAsync;
  50111. private _saveFileAsync;
  50112. /**
  50113. * Validates if xhr data is correct
  50114. * @param xhr defines the request to validate
  50115. * @param dataType defines the expected data type
  50116. * @returns true if data is correct
  50117. */
  50118. private static _ValidateXHRData;
  50119. }
  50120. }
  50121. declare module BABYLON {
  50122. /** @hidden */
  50123. export var gpuUpdateParticlesPixelShader: {
  50124. name: string;
  50125. shader: string;
  50126. };
  50127. }
  50128. declare module BABYLON {
  50129. /** @hidden */
  50130. export var gpuUpdateParticlesVertexShader: {
  50131. name: string;
  50132. shader: string;
  50133. };
  50134. }
  50135. declare module BABYLON {
  50136. /** @hidden */
  50137. export var clipPlaneFragmentDeclaration2: {
  50138. name: string;
  50139. shader: string;
  50140. };
  50141. }
  50142. declare module BABYLON {
  50143. /** @hidden */
  50144. export var gpuRenderParticlesPixelShader: {
  50145. name: string;
  50146. shader: string;
  50147. };
  50148. }
  50149. declare module BABYLON {
  50150. /** @hidden */
  50151. export var clipPlaneVertexDeclaration2: {
  50152. name: string;
  50153. shader: string;
  50154. };
  50155. }
  50156. declare module BABYLON {
  50157. /** @hidden */
  50158. export var gpuRenderParticlesVertexShader: {
  50159. name: string;
  50160. shader: string;
  50161. };
  50162. }
  50163. declare module BABYLON {
  50164. /**
  50165. * This represents a GPU particle system in Babylon
  50166. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  50167. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  50168. */
  50169. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  50170. /**
  50171. * The layer mask we are rendering the particles through.
  50172. */
  50173. layerMask: number;
  50174. private _capacity;
  50175. private _activeCount;
  50176. private _currentActiveCount;
  50177. private _accumulatedCount;
  50178. private _renderEffect;
  50179. private _updateEffect;
  50180. private _buffer0;
  50181. private _buffer1;
  50182. private _spriteBuffer;
  50183. private _updateVAO;
  50184. private _renderVAO;
  50185. private _targetIndex;
  50186. private _sourceBuffer;
  50187. private _targetBuffer;
  50188. private _engine;
  50189. private _currentRenderId;
  50190. private _started;
  50191. private _stopped;
  50192. private _timeDelta;
  50193. private _randomTexture;
  50194. private _randomTexture2;
  50195. private _attributesStrideSize;
  50196. private _updateEffectOptions;
  50197. private _randomTextureSize;
  50198. private _actualFrame;
  50199. private readonly _rawTextureWidth;
  50200. /**
  50201. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  50202. */
  50203. static readonly IsSupported: boolean;
  50204. /**
  50205. * An event triggered when the system is disposed.
  50206. */
  50207. onDisposeObservable: Observable<GPUParticleSystem>;
  50208. /**
  50209. * Gets the maximum number of particles active at the same time.
  50210. * @returns The max number of active particles.
  50211. */
  50212. getCapacity(): number;
  50213. /**
  50214. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  50215. * to override the particles.
  50216. */
  50217. forceDepthWrite: boolean;
  50218. /**
  50219. * Gets or set the number of active particles
  50220. */
  50221. activeParticleCount: number;
  50222. private _preWarmDone;
  50223. /**
  50224. * Is this system ready to be used/rendered
  50225. * @return true if the system is ready
  50226. */
  50227. isReady(): boolean;
  50228. /**
  50229. * Gets if the system has been started. (Note: this will still be true after stop is called)
  50230. * @returns True if it has been started, otherwise false.
  50231. */
  50232. isStarted(): boolean;
  50233. /**
  50234. * Starts the particle system and begins to emit
  50235. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  50236. */
  50237. start(delay?: number): void;
  50238. /**
  50239. * Stops the particle system.
  50240. */
  50241. stop(): void;
  50242. /**
  50243. * Remove all active particles
  50244. */
  50245. reset(): void;
  50246. /**
  50247. * Returns the string "GPUParticleSystem"
  50248. * @returns a string containing the class name
  50249. */
  50250. getClassName(): string;
  50251. private _colorGradientsTexture;
  50252. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  50253. /**
  50254. * Adds a new color gradient
  50255. * @param gradient defines the gradient to use (between 0 and 1)
  50256. * @param color1 defines the color to affect to the specified gradient
  50257. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  50258. * @returns the current particle system
  50259. */
  50260. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  50261. /**
  50262. * Remove a specific color gradient
  50263. * @param gradient defines the gradient to remove
  50264. * @returns the current particle system
  50265. */
  50266. removeColorGradient(gradient: number): GPUParticleSystem;
  50267. private _angularSpeedGradientsTexture;
  50268. private _sizeGradientsTexture;
  50269. private _velocityGradientsTexture;
  50270. private _limitVelocityGradientsTexture;
  50271. private _dragGradientsTexture;
  50272. private _addFactorGradient;
  50273. /**
  50274. * Adds a new size gradient
  50275. * @param gradient defines the gradient to use (between 0 and 1)
  50276. * @param factor defines the size factor to affect to the specified gradient
  50277. * @returns the current particle system
  50278. */
  50279. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  50280. /**
  50281. * Remove a specific size gradient
  50282. * @param gradient defines the gradient to remove
  50283. * @returns the current particle system
  50284. */
  50285. removeSizeGradient(gradient: number): GPUParticleSystem;
  50286. /**
  50287. * Adds a new angular speed gradient
  50288. * @param gradient defines the gradient to use (between 0 and 1)
  50289. * @param factor defines the angular speed to affect to the specified gradient
  50290. * @returns the current particle system
  50291. */
  50292. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  50293. /**
  50294. * Remove a specific angular speed gradient
  50295. * @param gradient defines the gradient to remove
  50296. * @returns the current particle system
  50297. */
  50298. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  50299. /**
  50300. * Adds a new velocity gradient
  50301. * @param gradient defines the gradient to use (between 0 and 1)
  50302. * @param factor defines the velocity to affect to the specified gradient
  50303. * @returns the current particle system
  50304. */
  50305. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50306. /**
  50307. * Remove a specific velocity gradient
  50308. * @param gradient defines the gradient to remove
  50309. * @returns the current particle system
  50310. */
  50311. removeVelocityGradient(gradient: number): GPUParticleSystem;
  50312. /**
  50313. * Adds a new limit velocity gradient
  50314. * @param gradient defines the gradient to use (between 0 and 1)
  50315. * @param factor defines the limit velocity value to affect to the specified gradient
  50316. * @returns the current particle system
  50317. */
  50318. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50319. /**
  50320. * Remove a specific limit velocity gradient
  50321. * @param gradient defines the gradient to remove
  50322. * @returns the current particle system
  50323. */
  50324. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  50325. /**
  50326. * Adds a new drag gradient
  50327. * @param gradient defines the gradient to use (between 0 and 1)
  50328. * @param factor defines the drag value to affect to the specified gradient
  50329. * @returns the current particle system
  50330. */
  50331. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  50332. /**
  50333. * Remove a specific drag gradient
  50334. * @param gradient defines the gradient to remove
  50335. * @returns the current particle system
  50336. */
  50337. removeDragGradient(gradient: number): GPUParticleSystem;
  50338. /**
  50339. * Not supported by GPUParticleSystem
  50340. * @param gradient defines the gradient to use (between 0 and 1)
  50341. * @param factor defines the emit rate value to affect to the specified gradient
  50342. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50343. * @returns the current particle system
  50344. */
  50345. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50346. /**
  50347. * Not supported by GPUParticleSystem
  50348. * @param gradient defines the gradient to remove
  50349. * @returns the current particle system
  50350. */
  50351. removeEmitRateGradient(gradient: number): IParticleSystem;
  50352. /**
  50353. * Not supported by GPUParticleSystem
  50354. * @param gradient defines the gradient to use (between 0 and 1)
  50355. * @param factor defines the start size value to affect to the specified gradient
  50356. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50357. * @returns the current particle system
  50358. */
  50359. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50360. /**
  50361. * Not supported by GPUParticleSystem
  50362. * @param gradient defines the gradient to remove
  50363. * @returns the current particle system
  50364. */
  50365. removeStartSizeGradient(gradient: number): IParticleSystem;
  50366. /**
  50367. * Not supported by GPUParticleSystem
  50368. * @param gradient defines the gradient to use (between 0 and 1)
  50369. * @param min defines the color remap minimal range
  50370. * @param max defines the color remap maximal range
  50371. * @returns the current particle system
  50372. */
  50373. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50374. /**
  50375. * Not supported by GPUParticleSystem
  50376. * @param gradient defines the gradient to remove
  50377. * @returns the current particle system
  50378. */
  50379. removeColorRemapGradient(): IParticleSystem;
  50380. /**
  50381. * Not supported by GPUParticleSystem
  50382. * @param gradient defines the gradient to use (between 0 and 1)
  50383. * @param min defines the alpha remap minimal range
  50384. * @param max defines the alpha remap maximal range
  50385. * @returns the current particle system
  50386. */
  50387. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50388. /**
  50389. * Not supported by GPUParticleSystem
  50390. * @param gradient defines the gradient to remove
  50391. * @returns the current particle system
  50392. */
  50393. removeAlphaRemapGradient(): IParticleSystem;
  50394. /**
  50395. * Not supported by GPUParticleSystem
  50396. * @param gradient defines the gradient to use (between 0 and 1)
  50397. * @param color defines the color to affect to the specified gradient
  50398. * @returns the current particle system
  50399. */
  50400. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  50401. /**
  50402. * Not supported by GPUParticleSystem
  50403. * @param gradient defines the gradient to remove
  50404. * @returns the current particle system
  50405. */
  50406. removeRampGradient(): IParticleSystem;
  50407. /**
  50408. * Not supported by GPUParticleSystem
  50409. * @returns the list of ramp gradients
  50410. */
  50411. getRampGradients(): Nullable<Array<Color3Gradient>>;
  50412. /**
  50413. * Not supported by GPUParticleSystem
  50414. * Gets or sets a boolean indicating that ramp gradients must be used
  50415. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  50416. */
  50417. useRampGradients: boolean;
  50418. /**
  50419. * Not supported by GPUParticleSystem
  50420. * @param gradient defines the gradient to use (between 0 and 1)
  50421. * @param factor defines the life time factor to affect to the specified gradient
  50422. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50423. * @returns the current particle system
  50424. */
  50425. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50426. /**
  50427. * Not supported by GPUParticleSystem
  50428. * @param gradient defines the gradient to remove
  50429. * @returns the current particle system
  50430. */
  50431. removeLifeTimeGradient(gradient: number): IParticleSystem;
  50432. /**
  50433. * Instantiates a GPU particle system.
  50434. * 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.
  50435. * @param name The name of the particle system
  50436. * @param options The options used to create the system
  50437. * @param scene The scene the particle system belongs to
  50438. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  50439. */
  50440. constructor(name: string, options: Partial<{
  50441. capacity: number;
  50442. randomTextureSize: number;
  50443. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  50444. protected _reset(): void;
  50445. private _createUpdateVAO;
  50446. private _createRenderVAO;
  50447. private _initialize;
  50448. /** @hidden */ recreateUpdateEffect(): void;
  50449. /** @hidden */ recreateRenderEffect(): void;
  50450. /**
  50451. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  50452. * @param preWarm defines if we are in the pre-warmimg phase
  50453. */
  50454. animate(preWarm?: boolean): void;
  50455. private _createFactorGradientTexture;
  50456. private _createSizeGradientTexture;
  50457. private _createAngularSpeedGradientTexture;
  50458. private _createVelocityGradientTexture;
  50459. private _createLimitVelocityGradientTexture;
  50460. private _createDragGradientTexture;
  50461. private _createColorGradientTexture;
  50462. /**
  50463. * Renders the particle system in its current state
  50464. * @param preWarm defines if the system should only update the particles but not render them
  50465. * @returns the current number of particles
  50466. */
  50467. render(preWarm?: boolean): number;
  50468. /**
  50469. * Rebuilds the particle system
  50470. */
  50471. rebuild(): void;
  50472. private _releaseBuffers;
  50473. private _releaseVAOs;
  50474. /**
  50475. * Disposes the particle system and free the associated resources
  50476. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  50477. */
  50478. dispose(disposeTexture?: boolean): void;
  50479. /**
  50480. * Clones the particle system.
  50481. * @param name The name of the cloned object
  50482. * @param newEmitter The new emitter to use
  50483. * @returns the cloned particle system
  50484. */
  50485. clone(name: string, newEmitter: any): GPUParticleSystem;
  50486. /**
  50487. * Serializes the particle system to a JSON object.
  50488. * @returns the JSON object
  50489. */
  50490. serialize(): any;
  50491. /**
  50492. * Parses a JSON object to create a GPU particle system.
  50493. * @param parsedParticleSystem The JSON object to parse
  50494. * @param scene The scene to create the particle system in
  50495. * @param rootUrl The root url to use to load external dependencies like texture
  50496. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  50497. * @returns the parsed GPU particle system
  50498. */
  50499. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  50500. }
  50501. }
  50502. declare module BABYLON {
  50503. /**
  50504. * Represents a set of particle systems working together to create a specific effect
  50505. */
  50506. export class ParticleSystemSet implements IDisposable {
  50507. private _emitterCreationOptions;
  50508. private _emitterNode;
  50509. /**
  50510. * Gets the particle system list
  50511. */
  50512. systems: IParticleSystem[];
  50513. /**
  50514. * Gets the emitter node used with this set
  50515. */
  50516. readonly emitterNode: Nullable<TransformNode>;
  50517. /**
  50518. * Creates a new emitter mesh as a sphere
  50519. * @param options defines the options used to create the sphere
  50520. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  50521. * @param scene defines the hosting scene
  50522. */
  50523. setEmitterAsSphere(options: {
  50524. diameter: number;
  50525. segments: number;
  50526. color: Color3;
  50527. }, renderingGroupId: number, scene: Scene): void;
  50528. /**
  50529. * Starts all particle systems of the set
  50530. * @param emitter defines an optional mesh to use as emitter for the particle systems
  50531. */
  50532. start(emitter?: AbstractMesh): void;
  50533. /**
  50534. * Release all associated resources
  50535. */
  50536. dispose(): void;
  50537. /**
  50538. * Serialize the set into a JSON compatible object
  50539. * @returns a JSON compatible representation of the set
  50540. */
  50541. serialize(): any;
  50542. /**
  50543. * Parse a new ParticleSystemSet from a serialized source
  50544. * @param data defines a JSON compatible representation of the set
  50545. * @param scene defines the hosting scene
  50546. * @param gpu defines if we want GPU particles or CPU particles
  50547. * @returns a new ParticleSystemSet
  50548. */
  50549. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  50550. }
  50551. }
  50552. declare module BABYLON {
  50553. /**
  50554. * This class is made for on one-liner static method to help creating particle system set.
  50555. */
  50556. export class ParticleHelper {
  50557. /**
  50558. * Gets or sets base Assets URL
  50559. */
  50560. static BaseAssetsUrl: string;
  50561. /**
  50562. * Create a default particle system that you can tweak
  50563. * @param emitter defines the emitter to use
  50564. * @param capacity defines the system capacity (default is 500 particles)
  50565. * @param scene defines the hosting scene
  50566. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  50567. * @returns the new Particle system
  50568. */
  50569. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  50570. /**
  50571. * This is the main static method (one-liner) of this helper to create different particle systems
  50572. * @param type This string represents the type to the particle system to create
  50573. * @param scene The scene where the particle system should live
  50574. * @param gpu If the system will use gpu
  50575. * @returns the ParticleSystemSet created
  50576. */
  50577. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  50578. /**
  50579. * Static function used to export a particle system to a ParticleSystemSet variable.
  50580. * Please note that the emitter shape is not exported
  50581. * @param systems defines the particle systems to export
  50582. * @returns the created particle system set
  50583. */
  50584. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  50585. }
  50586. }
  50587. declare module BABYLON {
  50588. interface Engine {
  50589. /**
  50590. * Create an effect to use with particle systems.
  50591. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  50592. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  50593. * @param uniformsNames defines a list of attribute names
  50594. * @param samplers defines an array of string used to represent textures
  50595. * @param defines defines the string containing the defines to use to compile the shaders
  50596. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  50597. * @param onCompiled defines a function to call when the effect creation is successful
  50598. * @param onError defines a function to call when the effect creation has failed
  50599. * @returns the new Effect
  50600. */
  50601. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  50602. }
  50603. interface Mesh {
  50604. /**
  50605. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  50606. * @returns an array of IParticleSystem
  50607. */
  50608. getEmittedParticleSystems(): IParticleSystem[];
  50609. /**
  50610. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  50611. * @returns an array of IParticleSystem
  50612. */
  50613. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  50614. }
  50615. /**
  50616. * @hidden
  50617. */
  50618. export var _IDoNeedToBeInTheBuild: number;
  50619. }
  50620. declare module BABYLON {
  50621. interface Scene {
  50622. /** @hidden (Backing field) */ physicsEngine: Nullable<IPhysicsEngine>;
  50623. /**
  50624. * Gets the current physics engine
  50625. * @returns a IPhysicsEngine or null if none attached
  50626. */
  50627. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  50628. /**
  50629. * Enables physics to the current scene
  50630. * @param gravity defines the scene's gravity for the physics engine
  50631. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  50632. * @return a boolean indicating if the physics engine was initialized
  50633. */
  50634. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  50635. /**
  50636. * Disables and disposes the physics engine associated with the scene
  50637. */
  50638. disablePhysicsEngine(): void;
  50639. /**
  50640. * Gets a boolean indicating if there is an active physics engine
  50641. * @returns a boolean indicating if there is an active physics engine
  50642. */
  50643. isPhysicsEnabled(): boolean;
  50644. /**
  50645. * Deletes a physics compound impostor
  50646. * @param compound defines the compound to delete
  50647. */
  50648. deleteCompoundImpostor(compound: any): void;
  50649. /**
  50650. * An event triggered when physic simulation is about to be run
  50651. */
  50652. onBeforePhysicsObservable: Observable<Scene>;
  50653. /**
  50654. * An event triggered when physic simulation has been done
  50655. */
  50656. onAfterPhysicsObservable: Observable<Scene>;
  50657. }
  50658. interface AbstractMesh {
  50659. /** @hidden */ physicsImpostor: Nullable<PhysicsImpostor>;
  50660. /**
  50661. * Gets or sets impostor used for physic simulation
  50662. * @see http://doc.babylonjs.com/features/physics_engine
  50663. */
  50664. physicsImpostor: Nullable<PhysicsImpostor>;
  50665. /**
  50666. * Gets the current physics impostor
  50667. * @see http://doc.babylonjs.com/features/physics_engine
  50668. * @returns a physics impostor or null
  50669. */
  50670. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  50671. /** Apply a physic impulse to the mesh
  50672. * @param force defines the force to apply
  50673. * @param contactPoint defines where to apply the force
  50674. * @returns the current mesh
  50675. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50676. */
  50677. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  50678. /**
  50679. * Creates a physic joint between two meshes
  50680. * @param otherMesh defines the other mesh to use
  50681. * @param pivot1 defines the pivot to use on this mesh
  50682. * @param pivot2 defines the pivot to use on the other mesh
  50683. * @param options defines additional options (can be plugin dependent)
  50684. * @returns the current mesh
  50685. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  50686. */
  50687. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  50688. /** @hidden */ disposePhysicsObserver: Nullable<Observer<Node>>;
  50689. }
  50690. /**
  50691. * Defines the physics engine scene component responsible to manage a physics engine
  50692. */
  50693. export class PhysicsEngineSceneComponent implements ISceneComponent {
  50694. /**
  50695. * The component name helpful to identify the component in the list of scene components.
  50696. */
  50697. readonly name: string;
  50698. /**
  50699. * The scene the component belongs to.
  50700. */
  50701. scene: Scene;
  50702. /**
  50703. * Creates a new instance of the component for the given scene
  50704. * @param scene Defines the scene to register the component in
  50705. */
  50706. constructor(scene: Scene);
  50707. /**
  50708. * Registers the component in a given scene
  50709. */
  50710. register(): void;
  50711. /**
  50712. * Rebuilds the elements related to this component in case of
  50713. * context lost for instance.
  50714. */
  50715. rebuild(): void;
  50716. /**
  50717. * Disposes the component and the associated ressources
  50718. */
  50719. dispose(): void;
  50720. }
  50721. }
  50722. declare module BABYLON {
  50723. /**
  50724. * A helper for physics simulations
  50725. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50726. */
  50727. export class PhysicsHelper {
  50728. private _scene;
  50729. private _physicsEngine;
  50730. /**
  50731. * Initializes the Physics helper
  50732. * @param scene Babylon.js scene
  50733. */
  50734. constructor(scene: Scene);
  50735. /**
  50736. * Applies a radial explosion impulse
  50737. * @param origin the origin of the explosion
  50738. * @param radiusOrEventOptions the radius or the options of radial explosion
  50739. * @param strength the explosion strength
  50740. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50741. * @returns A physics radial explosion event, or null
  50742. */
  50743. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50744. /**
  50745. * Applies a radial explosion force
  50746. * @param origin the origin of the explosion
  50747. * @param radiusOrEventOptions the radius or the options of radial explosion
  50748. * @param strength the explosion strength
  50749. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50750. * @returns A physics radial explosion event, or null
  50751. */
  50752. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50753. /**
  50754. * Creates a gravitational field
  50755. * @param origin the origin of the explosion
  50756. * @param radiusOrEventOptions the radius or the options of radial explosion
  50757. * @param strength the explosion strength
  50758. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50759. * @returns A physics gravitational field event, or null
  50760. */
  50761. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  50762. /**
  50763. * Creates a physics updraft event
  50764. * @param origin the origin of the updraft
  50765. * @param radiusOrEventOptions the radius or the options of the updraft
  50766. * @param strength the strength of the updraft
  50767. * @param height the height of the updraft
  50768. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  50769. * @returns A physics updraft event, or null
  50770. */
  50771. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  50772. /**
  50773. * Creates a physics vortex event
  50774. * @param origin the of the vortex
  50775. * @param radiusOrEventOptions the radius or the options of the vortex
  50776. * @param strength the strength of the vortex
  50777. * @param height the height of the vortex
  50778. * @returns a Physics vortex event, or null
  50779. * A physics vortex event or null
  50780. */
  50781. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  50782. }
  50783. /**
  50784. * Represents a physics radial explosion event
  50785. */
  50786. class PhysicsRadialExplosionEvent {
  50787. private _scene;
  50788. private _options;
  50789. private _sphere;
  50790. private _dataFetched;
  50791. /**
  50792. * Initializes a radial explosioin event
  50793. * @param _scene BabylonJS scene
  50794. * @param _options The options for the vortex event
  50795. */
  50796. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  50797. /**
  50798. * Returns the data related to the radial explosion event (sphere).
  50799. * @returns The radial explosion event data
  50800. */
  50801. getData(): PhysicsRadialExplosionEventData;
  50802. /**
  50803. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  50804. * @param impostor A physics imposter
  50805. * @param origin the origin of the explosion
  50806. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  50807. */
  50808. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  50809. /**
  50810. * Triggers affecterd impostors callbacks
  50811. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  50812. */
  50813. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  50814. /**
  50815. * Disposes the sphere.
  50816. * @param force Specifies if the sphere should be disposed by force
  50817. */
  50818. dispose(force?: boolean): void;
  50819. /*** Helpers ***/
  50820. private _prepareSphere;
  50821. private _intersectsWithSphere;
  50822. }
  50823. /**
  50824. * Represents a gravitational field event
  50825. */
  50826. class PhysicsGravitationalFieldEvent {
  50827. private _physicsHelper;
  50828. private _scene;
  50829. private _origin;
  50830. private _options;
  50831. private _tickCallback;
  50832. private _sphere;
  50833. private _dataFetched;
  50834. /**
  50835. * Initializes the physics gravitational field event
  50836. * @param _physicsHelper A physics helper
  50837. * @param _scene BabylonJS scene
  50838. * @param _origin The origin position of the gravitational field event
  50839. * @param _options The options for the vortex event
  50840. */
  50841. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  50842. /**
  50843. * Returns the data related to the gravitational field event (sphere).
  50844. * @returns A gravitational field event
  50845. */
  50846. getData(): PhysicsGravitationalFieldEventData;
  50847. /**
  50848. * Enables the gravitational field.
  50849. */
  50850. enable(): void;
  50851. /**
  50852. * Disables the gravitational field.
  50853. */
  50854. disable(): void;
  50855. /**
  50856. * Disposes the sphere.
  50857. * @param force The force to dispose from the gravitational field event
  50858. */
  50859. dispose(force?: boolean): void;
  50860. private _tick;
  50861. }
  50862. /**
  50863. * Represents a physics updraft event
  50864. */
  50865. class PhysicsUpdraftEvent {
  50866. private _scene;
  50867. private _origin;
  50868. private _options;
  50869. private _physicsEngine;
  50870. private _originTop;
  50871. private _originDirection;
  50872. private _tickCallback;
  50873. private _cylinder;
  50874. private _cylinderPosition;
  50875. private _dataFetched;
  50876. /**
  50877. * Initializes the physics updraft event
  50878. * @param _scene BabylonJS scene
  50879. * @param _origin The origin position of the updraft
  50880. * @param _options The options for the updraft event
  50881. */
  50882. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  50883. /**
  50884. * Returns the data related to the updraft event (cylinder).
  50885. * @returns A physics updraft event
  50886. */
  50887. getData(): PhysicsUpdraftEventData;
  50888. /**
  50889. * Enables the updraft.
  50890. */
  50891. enable(): void;
  50892. /**
  50893. * Disables the updraft.
  50894. */
  50895. disable(): void;
  50896. /**
  50897. * Disposes the cylinder.
  50898. * @param force Specifies if the updraft should be disposed by force
  50899. */
  50900. dispose(force?: boolean): void;
  50901. private getImpostorHitData;
  50902. private _tick;
  50903. /*** Helpers ***/
  50904. private _prepareCylinder;
  50905. private _intersectsWithCylinder;
  50906. }
  50907. /**
  50908. * Represents a physics vortex event
  50909. */
  50910. class PhysicsVortexEvent {
  50911. private _scene;
  50912. private _origin;
  50913. private _options;
  50914. private _physicsEngine;
  50915. private _originTop;
  50916. private _tickCallback;
  50917. private _cylinder;
  50918. private _cylinderPosition;
  50919. private _dataFetched;
  50920. /**
  50921. * Initializes the physics vortex event
  50922. * @param _scene The BabylonJS scene
  50923. * @param _origin The origin position of the vortex
  50924. * @param _options The options for the vortex event
  50925. */
  50926. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  50927. /**
  50928. * Returns the data related to the vortex event (cylinder).
  50929. * @returns The physics vortex event data
  50930. */
  50931. getData(): PhysicsVortexEventData;
  50932. /**
  50933. * Enables the vortex.
  50934. */
  50935. enable(): void;
  50936. /**
  50937. * Disables the cortex.
  50938. */
  50939. disable(): void;
  50940. /**
  50941. * Disposes the sphere.
  50942. * @param force
  50943. */
  50944. dispose(force?: boolean): void;
  50945. private getImpostorHitData;
  50946. private _tick;
  50947. /*** Helpers ***/
  50948. private _prepareCylinder;
  50949. private _intersectsWithCylinder;
  50950. }
  50951. /**
  50952. * Options fot the radial explosion event
  50953. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50954. */
  50955. export class PhysicsRadialExplosionEventOptions {
  50956. /**
  50957. * The radius of the sphere for the radial explosion.
  50958. */
  50959. radius: number;
  50960. /**
  50961. * The strenth of the explosion.
  50962. */
  50963. strength: number;
  50964. /**
  50965. * The strenght of the force in correspondence to the distance of the affected object
  50966. */
  50967. falloff: PhysicsRadialImpulseFalloff;
  50968. /**
  50969. * Sphere options for the radial explosion.
  50970. */
  50971. sphere: {
  50972. segments: number;
  50973. diameter: number;
  50974. };
  50975. /**
  50976. * Sphere options for the radial explosion.
  50977. */
  50978. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  50979. }
  50980. /**
  50981. * Options fot the updraft event
  50982. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50983. */
  50984. export class PhysicsUpdraftEventOptions {
  50985. /**
  50986. * The radius of the cylinder for the vortex
  50987. */
  50988. radius: number;
  50989. /**
  50990. * The strenth of the updraft.
  50991. */
  50992. strength: number;
  50993. /**
  50994. * The height of the cylinder for the updraft.
  50995. */
  50996. height: number;
  50997. /**
  50998. * The mode for the the updraft.
  50999. */
  51000. updraftMode: PhysicsUpdraftMode;
  51001. }
  51002. /**
  51003. * Options fot the vortex event
  51004. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51005. */
  51006. export class PhysicsVortexEventOptions {
  51007. /**
  51008. * The radius of the cylinder for the vortex
  51009. */
  51010. radius: number;
  51011. /**
  51012. * The strenth of the vortex.
  51013. */
  51014. strength: number;
  51015. /**
  51016. * The height of the cylinder for the vortex.
  51017. */
  51018. height: number;
  51019. /**
  51020. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  51021. */
  51022. centripetalForceThreshold: number;
  51023. /**
  51024. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  51025. */
  51026. centripetalForceMultiplier: number;
  51027. /**
  51028. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  51029. */
  51030. centrifugalForceMultiplier: number;
  51031. /**
  51032. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  51033. */
  51034. updraftForceMultiplier: number;
  51035. }
  51036. /**
  51037. * The strenght of the force in correspondence to the distance of the affected object
  51038. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51039. */
  51040. export enum PhysicsRadialImpulseFalloff {
  51041. /** Defines that impulse is constant in strength across it's whole radius */
  51042. Constant = 0,
  51043. /** Defines that impulse gets weaker if it's further from the origin */
  51044. Linear = 1
  51045. }
  51046. /**
  51047. * The strength of the force in correspondence to the distance of the affected object
  51048. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51049. */
  51050. export enum PhysicsUpdraftMode {
  51051. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  51052. Center = 0,
  51053. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  51054. Perpendicular = 1
  51055. }
  51056. /**
  51057. * Interface for a physics hit data
  51058. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51059. */
  51060. export interface PhysicsHitData {
  51061. /**
  51062. * The force applied at the contact point
  51063. */
  51064. force: Vector3;
  51065. /**
  51066. * The contact point
  51067. */
  51068. contactPoint: Vector3;
  51069. /**
  51070. * The distance from the origin to the contact point
  51071. */
  51072. distanceFromOrigin: number;
  51073. }
  51074. /**
  51075. * Interface for radial explosion event data
  51076. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51077. */
  51078. export interface PhysicsRadialExplosionEventData {
  51079. /**
  51080. * A sphere used for the radial explosion event
  51081. */
  51082. sphere: Mesh;
  51083. }
  51084. /**
  51085. * Interface for gravitational field event data
  51086. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51087. */
  51088. export interface PhysicsGravitationalFieldEventData {
  51089. /**
  51090. * A sphere mesh used for the gravitational field event
  51091. */
  51092. sphere: Mesh;
  51093. }
  51094. /**
  51095. * Interface for updraft event data
  51096. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51097. */
  51098. export interface PhysicsUpdraftEventData {
  51099. /**
  51100. * A cylinder used for the updraft event
  51101. */
  51102. cylinder: Mesh;
  51103. }
  51104. /**
  51105. * Interface for vortex event data
  51106. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51107. */
  51108. export interface PhysicsVortexEventData {
  51109. /**
  51110. * A cylinder used for the vortex event
  51111. */
  51112. cylinder: Mesh;
  51113. }
  51114. /**
  51115. * Interface for an affected physics impostor
  51116. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51117. */
  51118. export interface PhysicsAffectedImpostorWithData {
  51119. /**
  51120. * The impostor affected by the effect
  51121. */
  51122. impostor: PhysicsImpostor;
  51123. /**
  51124. * The data about the hit/horce from the explosion
  51125. */
  51126. hitData: PhysicsHitData;
  51127. }
  51128. }
  51129. declare module BABYLON {
  51130. /** @hidden */
  51131. export var blackAndWhitePixelShader: {
  51132. name: string;
  51133. shader: string;
  51134. };
  51135. }
  51136. declare module BABYLON {
  51137. /**
  51138. * Post process used to render in black and white
  51139. */
  51140. export class BlackAndWhitePostProcess extends PostProcess {
  51141. /**
  51142. * Linear about to convert he result to black and white (default: 1)
  51143. */
  51144. degree: number;
  51145. /**
  51146. * Creates a black and white post process
  51147. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  51148. * @param name The name of the effect.
  51149. * @param options The required width/height ratio to downsize to before computing the render pass.
  51150. * @param camera The camera to apply the render pass to.
  51151. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51152. * @param engine The engine which the post process will be applied. (default: current engine)
  51153. * @param reusable If the post process can be reused on the same frame. (default: false)
  51154. */
  51155. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51156. }
  51157. }
  51158. declare module BABYLON {
  51159. /**
  51160. * This represents a set of one or more post processes in Babylon.
  51161. * A post process can be used to apply a shader to a texture after it is rendered.
  51162. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51163. */
  51164. export class PostProcessRenderEffect {
  51165. private _postProcesses;
  51166. private _getPostProcesses;
  51167. private _singleInstance;
  51168. private _cameras;
  51169. private _indicesForCamera;
  51170. /**
  51171. * Name of the effect
  51172. * @hidden
  51173. */ name: string;
  51174. /**
  51175. * Instantiates a post process render effect.
  51176. * A post process can be used to apply a shader to a texture after it is rendered.
  51177. * @param engine The engine the effect is tied to
  51178. * @param name The name of the effect
  51179. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  51180. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  51181. */
  51182. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  51183. /**
  51184. * Checks if all the post processes in the effect are supported.
  51185. */
  51186. readonly isSupported: boolean;
  51187. /**
  51188. * Updates the current state of the effect
  51189. * @hidden
  51190. */ update(): void;
  51191. /**
  51192. * Attaches the effect on cameras
  51193. * @param cameras The camera to attach to.
  51194. * @hidden
  51195. */ attachCameras(cameras: Camera): void;
  51196. /**
  51197. * Attaches the effect on cameras
  51198. * @param cameras The camera to attach to.
  51199. * @hidden
  51200. */ attachCameras(cameras: Camera[]): void;
  51201. /**
  51202. * Detatches the effect on cameras
  51203. * @param cameras The camera to detatch from.
  51204. * @hidden
  51205. */ detachCameras(cameras: Camera): void;
  51206. /**
  51207. * Detatches the effect on cameras
  51208. * @param cameras The camera to detatch from.
  51209. * @hidden
  51210. */ detachCameras(cameras: Camera[]): void;
  51211. /**
  51212. * Enables the effect on given cameras
  51213. * @param cameras The camera to enable.
  51214. * @hidden
  51215. */ enable(cameras: Camera): void;
  51216. /**
  51217. * Enables the effect on given cameras
  51218. * @param cameras The camera to enable.
  51219. * @hidden
  51220. */ enable(cameras: Nullable<Camera[]>): void;
  51221. /**
  51222. * Disables the effect on the given cameras
  51223. * @param cameras The camera to disable.
  51224. * @hidden
  51225. */ disable(cameras: Camera): void;
  51226. /**
  51227. * Disables the effect on the given cameras
  51228. * @param cameras The camera to disable.
  51229. * @hidden
  51230. */ disable(cameras: Nullable<Camera[]>): void;
  51231. /**
  51232. * Gets a list of the post processes contained in the effect.
  51233. * @param camera The camera to get the post processes on.
  51234. * @returns The list of the post processes in the effect.
  51235. */
  51236. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  51237. }
  51238. }
  51239. declare module BABYLON {
  51240. /** @hidden */
  51241. export var extractHighlightsPixelShader: {
  51242. name: string;
  51243. shader: string;
  51244. };
  51245. }
  51246. declare module BABYLON {
  51247. /**
  51248. * 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.
  51249. */
  51250. export class ExtractHighlightsPostProcess extends PostProcess {
  51251. /**
  51252. * The luminance threshold, pixels below this value will be set to black.
  51253. */
  51254. threshold: number;
  51255. /** @hidden */ exposure: number;
  51256. /**
  51257. * Post process which has the input texture to be used when performing highlight extraction
  51258. * @hidden
  51259. */ inputPostProcess: Nullable<PostProcess>;
  51260. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51261. }
  51262. }
  51263. declare module BABYLON {
  51264. /** @hidden */
  51265. export var bloomMergePixelShader: {
  51266. name: string;
  51267. shader: string;
  51268. };
  51269. }
  51270. declare module BABYLON {
  51271. /**
  51272. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51273. */
  51274. export class BloomMergePostProcess extends PostProcess {
  51275. /** Weight of the bloom to be added to the original input. */
  51276. weight: number;
  51277. /**
  51278. * Creates a new instance of @see BloomMergePostProcess
  51279. * @param name The name of the effect.
  51280. * @param originalFromInput Post process which's input will be used for the merge.
  51281. * @param blurred Blurred highlights post process which's output will be used.
  51282. * @param weight Weight of the bloom to be added to the original input.
  51283. * @param options The required width/height ratio to downsize to before computing the render pass.
  51284. * @param camera The camera to apply the render pass to.
  51285. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51286. * @param engine The engine which the post process will be applied. (default: current engine)
  51287. * @param reusable If the post process can be reused on the same frame. (default: false)
  51288. * @param textureType Type of textures used when performing the post process. (default: 0)
  51289. * @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)
  51290. */
  51291. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  51292. /** Weight of the bloom to be added to the original input. */
  51293. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51294. }
  51295. }
  51296. declare module BABYLON {
  51297. /**
  51298. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  51299. */
  51300. export class BloomEffect extends PostProcessRenderEffect {
  51301. private bloomScale;
  51302. /**
  51303. * @hidden Internal
  51304. */ effects: Array<PostProcess>;
  51305. /**
  51306. * @hidden Internal
  51307. */ downscale: ExtractHighlightsPostProcess;
  51308. private _blurX;
  51309. private _blurY;
  51310. private _merge;
  51311. /**
  51312. * The luminance threshold to find bright areas of the image to bloom.
  51313. */
  51314. threshold: number;
  51315. /**
  51316. * The strength of the bloom.
  51317. */
  51318. weight: number;
  51319. /**
  51320. * Specifies the size of the bloom blur kernel, relative to the final output size
  51321. */
  51322. kernel: number;
  51323. /**
  51324. * Creates a new instance of @see BloomEffect
  51325. * @param scene The scene the effect belongs to.
  51326. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  51327. * @param bloomKernel The size of the kernel to be used when applying the blur.
  51328. * @param bloomWeight The the strength of bloom.
  51329. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51330. * @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)
  51331. */
  51332. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  51333. /**
  51334. * Disposes each of the internal effects for a given camera.
  51335. * @param camera The camera to dispose the effect on.
  51336. */
  51337. disposeEffects(camera: Camera): void;
  51338. /**
  51339. * @hidden Internal
  51340. */ updateEffects(): void;
  51341. /**
  51342. * Internal
  51343. * @returns if all the contained post processes are ready.
  51344. * @hidden
  51345. */ isReady(): boolean;
  51346. }
  51347. }
  51348. declare module BABYLON {
  51349. /** @hidden */
  51350. export var chromaticAberrationPixelShader: {
  51351. name: string;
  51352. shader: string;
  51353. };
  51354. }
  51355. declare module BABYLON {
  51356. /**
  51357. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  51358. */
  51359. export class ChromaticAberrationPostProcess extends PostProcess {
  51360. /**
  51361. * The amount of seperation of rgb channels (default: 30)
  51362. */
  51363. aberrationAmount: number;
  51364. /**
  51365. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  51366. */
  51367. radialIntensity: number;
  51368. /**
  51369. * 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))
  51370. */
  51371. direction: Vector2;
  51372. /**
  51373. * 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))
  51374. */
  51375. centerPosition: Vector2;
  51376. /**
  51377. * Creates a new instance ChromaticAberrationPostProcess
  51378. * @param name The name of the effect.
  51379. * @param screenWidth The width of the screen to apply the effect on.
  51380. * @param screenHeight The height of the screen to apply the effect on.
  51381. * @param options The required width/height ratio to downsize to before computing the render pass.
  51382. * @param camera The camera to apply the render pass to.
  51383. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51384. * @param engine The engine which the post process will be applied. (default: current engine)
  51385. * @param reusable If the post process can be reused on the same frame. (default: false)
  51386. * @param textureType Type of textures used when performing the post process. (default: 0)
  51387. * @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)
  51388. */
  51389. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51390. }
  51391. }
  51392. declare module BABYLON {
  51393. /** @hidden */
  51394. export var circleOfConfusionPixelShader: {
  51395. name: string;
  51396. shader: string;
  51397. };
  51398. }
  51399. declare module BABYLON {
  51400. /**
  51401. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  51402. */
  51403. export class CircleOfConfusionPostProcess extends PostProcess {
  51404. /**
  51405. * 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.
  51406. */
  51407. lensSize: number;
  51408. /**
  51409. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51410. */
  51411. fStop: number;
  51412. /**
  51413. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51414. */
  51415. focusDistance: number;
  51416. /**
  51417. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  51418. */
  51419. focalLength: number;
  51420. private _depthTexture;
  51421. /**
  51422. * Creates a new instance CircleOfConfusionPostProcess
  51423. * @param name The name of the effect.
  51424. * @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.
  51425. * @param options The required width/height ratio to downsize to before computing the render pass.
  51426. * @param camera The camera to apply the render pass to.
  51427. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51428. * @param engine The engine which the post process will be applied. (default: current engine)
  51429. * @param reusable If the post process can be reused on the same frame. (default: false)
  51430. * @param textureType Type of textures used when performing the post process. (default: 0)
  51431. * @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)
  51432. */
  51433. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51434. /**
  51435. * 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.
  51436. */
  51437. depthTexture: RenderTargetTexture;
  51438. }
  51439. }
  51440. declare module BABYLON {
  51441. /** @hidden */
  51442. export var colorCorrectionPixelShader: {
  51443. name: string;
  51444. shader: string;
  51445. };
  51446. }
  51447. declare module BABYLON {
  51448. /**
  51449. *
  51450. * This post-process allows the modification of rendered colors by using
  51451. * a 'look-up table' (LUT). This effect is also called Color Grading.
  51452. *
  51453. * The object needs to be provided an url to a texture containing the color
  51454. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  51455. * Use an image editing software to tweak the LUT to match your needs.
  51456. *
  51457. * For an example of a color LUT, see here:
  51458. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  51459. * For explanations on color grading, see here:
  51460. * @see http://udn.epicgames.com/Three/ColorGrading.html
  51461. *
  51462. */
  51463. export class ColorCorrectionPostProcess extends PostProcess {
  51464. private _colorTableTexture;
  51465. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51466. }
  51467. }
  51468. declare module BABYLON {
  51469. /** @hidden */
  51470. export var convolutionPixelShader: {
  51471. name: string;
  51472. shader: string;
  51473. };
  51474. }
  51475. declare module BABYLON {
  51476. /**
  51477. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  51478. * input texture to perform effects such as edge detection or sharpening
  51479. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  51480. */
  51481. export class ConvolutionPostProcess extends PostProcess {
  51482. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51483. kernel: number[];
  51484. /**
  51485. * Creates a new instance ConvolutionPostProcess
  51486. * @param name The name of the effect.
  51487. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  51488. * @param options The required width/height ratio to downsize to before computing the render pass.
  51489. * @param camera The camera to apply the render pass to.
  51490. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51491. * @param engine The engine which the post process will be applied. (default: current engine)
  51492. * @param reusable If the post process can be reused on the same frame. (default: false)
  51493. * @param textureType Type of textures used when performing the post process. (default: 0)
  51494. */
  51495. constructor(name: string,
  51496. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51497. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51498. /**
  51499. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51500. */
  51501. static EdgeDetect0Kernel: number[];
  51502. /**
  51503. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51504. */
  51505. static EdgeDetect1Kernel: number[];
  51506. /**
  51507. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51508. */
  51509. static EdgeDetect2Kernel: number[];
  51510. /**
  51511. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51512. */
  51513. static SharpenKernel: number[];
  51514. /**
  51515. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51516. */
  51517. static EmbossKernel: number[];
  51518. /**
  51519. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51520. */
  51521. static GaussianKernel: number[];
  51522. }
  51523. }
  51524. declare module BABYLON {
  51525. /**
  51526. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  51527. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  51528. * based on samples that have a large difference in distance than the center pixel.
  51529. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  51530. */
  51531. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  51532. direction: Vector2;
  51533. /**
  51534. * Creates a new instance CircleOfConfusionPostProcess
  51535. * @param name The name of the effect.
  51536. * @param scene The scene the effect belongs to.
  51537. * @param direction The direction the blur should be applied.
  51538. * @param kernel The size of the kernel used to blur.
  51539. * @param options The required width/height ratio to downsize to before computing the render pass.
  51540. * @param camera The camera to apply the render pass to.
  51541. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  51542. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  51543. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51544. * @param engine The engine which the post process will be applied. (default: current engine)
  51545. * @param reusable If the post process can be reused on the same frame. (default: false)
  51546. * @param textureType Type of textures used when performing the post process. (default: 0)
  51547. * @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)
  51548. */
  51549. 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);
  51550. }
  51551. }
  51552. declare module BABYLON {
  51553. /** @hidden */
  51554. export var depthOfFieldMergePixelShader: {
  51555. name: string;
  51556. shader: string;
  51557. };
  51558. }
  51559. declare module BABYLON {
  51560. /**
  51561. * Options to be set when merging outputs from the default pipeline.
  51562. */
  51563. export class DepthOfFieldMergePostProcessOptions {
  51564. /**
  51565. * The original image to merge on top of
  51566. */
  51567. originalFromInput: PostProcess;
  51568. /**
  51569. * Parameters to perform the merge of the depth of field effect
  51570. */
  51571. depthOfField?: {
  51572. circleOfConfusion: PostProcess;
  51573. blurSteps: Array<PostProcess>;
  51574. };
  51575. /**
  51576. * Parameters to perform the merge of bloom effect
  51577. */
  51578. bloom?: {
  51579. blurred: PostProcess;
  51580. weight: number;
  51581. };
  51582. }
  51583. /**
  51584. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51585. */
  51586. export class DepthOfFieldMergePostProcess extends PostProcess {
  51587. private blurSteps;
  51588. /**
  51589. * Creates a new instance of DepthOfFieldMergePostProcess
  51590. * @param name The name of the effect.
  51591. * @param originalFromInput Post process which's input will be used for the merge.
  51592. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  51593. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  51594. * @param options The required width/height ratio to downsize to before computing the render pass.
  51595. * @param camera The camera to apply the render pass to.
  51596. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51597. * @param engine The engine which the post process will be applied. (default: current engine)
  51598. * @param reusable If the post process can be reused on the same frame. (default: false)
  51599. * @param textureType Type of textures used when performing the post process. (default: 0)
  51600. * @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)
  51601. */
  51602. 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);
  51603. /**
  51604. * Updates the effect with the current post process compile time values and recompiles the shader.
  51605. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  51606. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  51607. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  51608. * @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
  51609. * @param onCompiled Called when the shader has been compiled.
  51610. * @param onError Called if there is an error when compiling a shader.
  51611. */
  51612. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  51613. }
  51614. }
  51615. declare module BABYLON {
  51616. /**
  51617. * Specifies the level of max blur that should be applied when using the depth of field effect
  51618. */
  51619. export enum DepthOfFieldEffectBlurLevel {
  51620. /**
  51621. * Subtle blur
  51622. */
  51623. Low = 0,
  51624. /**
  51625. * Medium blur
  51626. */
  51627. Medium = 1,
  51628. /**
  51629. * Large blur
  51630. */
  51631. High = 2
  51632. }
  51633. /**
  51634. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  51635. */
  51636. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  51637. private _circleOfConfusion;
  51638. /**
  51639. * @hidden Internal, blurs from high to low
  51640. */ depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  51641. private _depthOfFieldBlurY;
  51642. private _dofMerge;
  51643. /**
  51644. * @hidden Internal post processes in depth of field effect
  51645. */ effects: Array<PostProcess>;
  51646. /**
  51647. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  51648. */
  51649. focalLength: number;
  51650. /**
  51651. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51652. */
  51653. fStop: number;
  51654. /**
  51655. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51656. */
  51657. focusDistance: number;
  51658. /**
  51659. * 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.
  51660. */
  51661. lensSize: number;
  51662. /**
  51663. * Creates a new instance DepthOfFieldEffect
  51664. * @param scene The scene the effect belongs to.
  51665. * @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.
  51666. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51667. * @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)
  51668. */
  51669. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  51670. /**
  51671. * 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.
  51672. */
  51673. depthTexture: RenderTargetTexture;
  51674. /**
  51675. * Disposes each of the internal effects for a given camera.
  51676. * @param camera The camera to dispose the effect on.
  51677. */
  51678. disposeEffects(camera: Camera): void;
  51679. /**
  51680. * @hidden Internal
  51681. */ updateEffects(): void;
  51682. /**
  51683. * Internal
  51684. * @returns if all the contained post processes are ready.
  51685. * @hidden
  51686. */ isReady(): boolean;
  51687. }
  51688. }
  51689. declare module BABYLON {
  51690. /** @hidden */
  51691. export var displayPassPixelShader: {
  51692. name: string;
  51693. shader: string;
  51694. };
  51695. }
  51696. declare module BABYLON {
  51697. /**
  51698. * DisplayPassPostProcess which produces an output the same as it's input
  51699. */
  51700. export class DisplayPassPostProcess extends PostProcess {
  51701. /**
  51702. * Creates the DisplayPassPostProcess
  51703. * @param name The name of the effect.
  51704. * @param options The required width/height ratio to downsize to before computing the render pass.
  51705. * @param camera The camera to apply the render pass to.
  51706. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51707. * @param engine The engine which the post process will be applied. (default: current engine)
  51708. * @param reusable If the post process can be reused on the same frame. (default: false)
  51709. */
  51710. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51711. }
  51712. }
  51713. declare module BABYLON {
  51714. /** @hidden */
  51715. export var filterPixelShader: {
  51716. name: string;
  51717. shader: string;
  51718. };
  51719. }
  51720. declare module BABYLON {
  51721. /**
  51722. * Applies a kernel filter to the image
  51723. */
  51724. export class FilterPostProcess extends PostProcess {
  51725. /** The matrix to be applied to the image */
  51726. kernelMatrix: Matrix;
  51727. /**
  51728. *
  51729. * @param name The name of the effect.
  51730. * @param kernelMatrix The matrix to be applied to the image
  51731. * @param options The required width/height ratio to downsize to before computing the render pass.
  51732. * @param camera The camera to apply the render pass to.
  51733. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51734. * @param engine The engine which the post process will be applied. (default: current engine)
  51735. * @param reusable If the post process can be reused on the same frame. (default: false)
  51736. */
  51737. constructor(name: string,
  51738. /** The matrix to be applied to the image */
  51739. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51740. }
  51741. }
  51742. declare module BABYLON {
  51743. /** @hidden */
  51744. export var fxaaPixelShader: {
  51745. name: string;
  51746. shader: string;
  51747. };
  51748. }
  51749. declare module BABYLON {
  51750. /** @hidden */
  51751. export var fxaaVertexShader: {
  51752. name: string;
  51753. shader: string;
  51754. };
  51755. }
  51756. declare module BABYLON {
  51757. /**
  51758. * Fxaa post process
  51759. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  51760. */
  51761. export class FxaaPostProcess extends PostProcess {
  51762. /** @hidden */
  51763. texelWidth: number;
  51764. /** @hidden */
  51765. texelHeight: number;
  51766. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51767. private _getDefines;
  51768. }
  51769. }
  51770. declare module BABYLON {
  51771. /** @hidden */
  51772. export var grainPixelShader: {
  51773. name: string;
  51774. shader: string;
  51775. };
  51776. }
  51777. declare module BABYLON {
  51778. /**
  51779. * The GrainPostProcess adds noise to the image at mid luminance levels
  51780. */
  51781. export class GrainPostProcess extends PostProcess {
  51782. /**
  51783. * The intensity of the grain added (default: 30)
  51784. */
  51785. intensity: number;
  51786. /**
  51787. * If the grain should be randomized on every frame
  51788. */
  51789. animated: boolean;
  51790. /**
  51791. * Creates a new instance of @see GrainPostProcess
  51792. * @param name The name of the effect.
  51793. * @param options The required width/height ratio to downsize to before computing the render pass.
  51794. * @param camera The camera to apply the render pass to.
  51795. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51796. * @param engine The engine which the post process will be applied. (default: current engine)
  51797. * @param reusable If the post process can be reused on the same frame. (default: false)
  51798. * @param textureType Type of textures used when performing the post process. (default: 0)
  51799. * @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)
  51800. */
  51801. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51802. }
  51803. }
  51804. declare module BABYLON {
  51805. /** @hidden */
  51806. export var highlightsPixelShader: {
  51807. name: string;
  51808. shader: string;
  51809. };
  51810. }
  51811. declare module BABYLON {
  51812. /**
  51813. * Extracts highlights from the image
  51814. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  51815. */
  51816. export class HighlightsPostProcess extends PostProcess {
  51817. /**
  51818. * Extracts highlights from the image
  51819. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  51820. * @param name The name of the effect.
  51821. * @param options The required width/height ratio to downsize to before computing the render pass.
  51822. * @param camera The camera to apply the render pass to.
  51823. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51824. * @param engine The engine which the post process will be applied. (default: current engine)
  51825. * @param reusable If the post process can be reused on the same frame. (default: false)
  51826. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  51827. */
  51828. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51829. }
  51830. }
  51831. declare module BABYLON {
  51832. /** @hidden */
  51833. export var mrtFragmentDeclaration: {
  51834. name: string;
  51835. shader: string;
  51836. };
  51837. }
  51838. declare module BABYLON {
  51839. /** @hidden */
  51840. export var geometryPixelShader: {
  51841. name: string;
  51842. shader: string;
  51843. };
  51844. }
  51845. declare module BABYLON {
  51846. /** @hidden */
  51847. export var geometryVertexShader: {
  51848. name: string;
  51849. shader: string;
  51850. };
  51851. }
  51852. declare module BABYLON {
  51853. /**
  51854. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  51855. */
  51856. export class GeometryBufferRenderer {
  51857. /**
  51858. * Constant used to retrieve the position texture index in the G-Buffer textures array
  51859. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  51860. */
  51861. static readonly POSITION_TEXTURE_TYPE: number;
  51862. /**
  51863. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  51864. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  51865. */
  51866. static readonly VELOCITY_TEXTURE_TYPE: number;
  51867. /**
  51868. * Dictionary used to store the previous transformation matrices of each rendered mesh
  51869. * in order to compute objects velocities when enableVelocity is set to "true"
  51870. * @hidden
  51871. */ previousTransformationMatrices: {
  51872. [index: number]: Matrix;
  51873. };
  51874. private _scene;
  51875. private _multiRenderTarget;
  51876. private _ratio;
  51877. private _enablePosition;
  51878. private _enableVelocity;
  51879. private _positionIndex;
  51880. private _velocityIndex;
  51881. protected _effect: Effect;
  51882. protected _cachedDefines: string;
  51883. /**
  51884. * Set the render list (meshes to be rendered) used in the G buffer.
  51885. */
  51886. renderList: Mesh[];
  51887. /**
  51888. * Gets wether or not G buffer are supported by the running hardware.
  51889. * This requires draw buffer supports
  51890. */
  51891. readonly isSupported: boolean;
  51892. /**
  51893. * Returns the index of the given texture type in the G-Buffer textures array
  51894. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  51895. * @returns the index of the given texture type in the G-Buffer textures array
  51896. */
  51897. getTextureIndex(textureType: number): number;
  51898. /**
  51899. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  51900. */
  51901. /**
  51902. * Sets whether or not objects positions are enabled for the G buffer.
  51903. */
  51904. enablePosition: boolean;
  51905. /**
  51906. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  51907. */
  51908. /**
  51909. * Sets wether or not objects velocities are enabled for the G buffer.
  51910. */
  51911. enableVelocity: boolean;
  51912. /**
  51913. * Gets the scene associated with the buffer.
  51914. */
  51915. readonly scene: Scene;
  51916. /**
  51917. * Gets the ratio used by the buffer during its creation.
  51918. * How big is the buffer related to the main canvas.
  51919. */
  51920. readonly ratio: number;
  51921. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  51922. /**
  51923. * Creates a new G Buffer for the scene
  51924. * @param scene The scene the buffer belongs to
  51925. * @param ratio How big is the buffer related to the main canvas.
  51926. */
  51927. constructor(scene: Scene, ratio?: number);
  51928. /**
  51929. * Checks wether everything is ready to render a submesh to the G buffer.
  51930. * @param subMesh the submesh to check readiness for
  51931. * @param useInstances is the mesh drawn using instance or not
  51932. * @returns true if ready otherwise false
  51933. */
  51934. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51935. /**
  51936. * Gets the current underlying G Buffer.
  51937. * @returns the buffer
  51938. */
  51939. getGBuffer(): MultiRenderTarget;
  51940. /**
  51941. * Gets the number of samples used to render the buffer (anti aliasing).
  51942. */
  51943. /**
  51944. * Sets the number of samples used to render the buffer (anti aliasing).
  51945. */
  51946. samples: number;
  51947. /**
  51948. * Disposes the renderer and frees up associated resources.
  51949. */
  51950. dispose(): void;
  51951. protected _createRenderTargets(): void;
  51952. }
  51953. }
  51954. declare module BABYLON {
  51955. interface Scene {
  51956. /** @hidden (Backing field) */ geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  51957. /**
  51958. * Gets or Sets the current geometry buffer associated to the scene.
  51959. */
  51960. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  51961. /**
  51962. * Enables a GeometryBufferRender and associates it with the scene
  51963. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  51964. * @returns the GeometryBufferRenderer
  51965. */
  51966. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  51967. /**
  51968. * Disables the GeometryBufferRender associated with the scene
  51969. */
  51970. disableGeometryBufferRenderer(): void;
  51971. }
  51972. /**
  51973. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  51974. * in several rendering techniques.
  51975. */
  51976. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  51977. /**
  51978. * The component name helpful to identify the component in the list of scene components.
  51979. */
  51980. readonly name: string;
  51981. /**
  51982. * The scene the component belongs to.
  51983. */
  51984. scene: Scene;
  51985. /**
  51986. * Creates a new instance of the component for the given scene
  51987. * @param scene Defines the scene to register the component in
  51988. */
  51989. constructor(scene: Scene);
  51990. /**
  51991. * Registers the component in a given scene
  51992. */
  51993. register(): void;
  51994. /**
  51995. * Rebuilds the elements related to this component in case of
  51996. * context lost for instance.
  51997. */
  51998. rebuild(): void;
  51999. /**
  52000. * Disposes the component and the associated ressources
  52001. */
  52002. dispose(): void;
  52003. private _gatherRenderTargets;
  52004. }
  52005. }
  52006. declare module BABYLON {
  52007. /** @hidden */
  52008. export var motionBlurPixelShader: {
  52009. name: string;
  52010. shader: string;
  52011. };
  52012. }
  52013. declare module BABYLON {
  52014. /**
  52015. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  52016. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  52017. * As an example, all you have to do is to create the post-process:
  52018. * var mb = new BABYLON.MotionBlurPostProcess(
  52019. * 'mb', // The name of the effect.
  52020. * scene, // The scene containing the objects to blur according to their velocity.
  52021. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  52022. * camera // The camera to apply the render pass to.
  52023. * );
  52024. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  52025. */
  52026. export class MotionBlurPostProcess extends PostProcess {
  52027. /**
  52028. * Defines how much the image is blurred by the movement. Default value is equal to 1
  52029. */
  52030. motionStrength: number;
  52031. /**
  52032. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  52033. */
  52034. /**
  52035. * Sets the number of iterations to be used for motion blur quality
  52036. */
  52037. motionBlurSamples: number;
  52038. private _motionBlurSamples;
  52039. private _geometryBufferRenderer;
  52040. /**
  52041. * Creates a new instance MotionBlurPostProcess
  52042. * @param name The name of the effect.
  52043. * @param scene The scene containing the objects to blur according to their velocity.
  52044. * @param options The required width/height ratio to downsize to before computing the render pass.
  52045. * @param camera The camera to apply the render pass to.
  52046. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52047. * @param engine The engine which the post process will be applied. (default: current engine)
  52048. * @param reusable If the post process can be reused on the same frame. (default: false)
  52049. * @param textureType Type of textures used when performing the post process. (default: 0)
  52050. * @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)
  52051. */
  52052. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52053. /**
  52054. * Disposes the post process.
  52055. * @param camera The camera to dispose the post process on.
  52056. */
  52057. dispose(camera?: Camera): void;
  52058. }
  52059. }
  52060. declare module BABYLON {
  52061. /** @hidden */
  52062. export var refractionPixelShader: {
  52063. name: string;
  52064. shader: string;
  52065. };
  52066. }
  52067. declare module BABYLON {
  52068. /**
  52069. * Post process which applies a refractin texture
  52070. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52071. */
  52072. export class RefractionPostProcess extends PostProcess {
  52073. /** the base color of the refraction (used to taint the rendering) */
  52074. color: Color3;
  52075. /** simulated refraction depth */
  52076. depth: number;
  52077. /** the coefficient of the base color (0 to remove base color tainting) */
  52078. colorLevel: number;
  52079. private _refTexture;
  52080. private _ownRefractionTexture;
  52081. /**
  52082. * Gets or sets the refraction texture
  52083. * Please note that you are responsible for disposing the texture if you set it manually
  52084. */
  52085. refractionTexture: Texture;
  52086. /**
  52087. * Initializes the RefractionPostProcess
  52088. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52089. * @param name The name of the effect.
  52090. * @param refractionTextureUrl Url of the refraction texture to use
  52091. * @param color the base color of the refraction (used to taint the rendering)
  52092. * @param depth simulated refraction depth
  52093. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  52094. * @param camera The camera to apply the render pass to.
  52095. * @param options The required width/height ratio to downsize to before computing the render pass.
  52096. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52097. * @param engine The engine which the post process will be applied. (default: current engine)
  52098. * @param reusable If the post process can be reused on the same frame. (default: false)
  52099. */
  52100. constructor(name: string, refractionTextureUrl: string,
  52101. /** the base color of the refraction (used to taint the rendering) */
  52102. color: Color3,
  52103. /** simulated refraction depth */
  52104. depth: number,
  52105. /** the coefficient of the base color (0 to remove base color tainting) */
  52106. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52107. /**
  52108. * Disposes of the post process
  52109. * @param camera Camera to dispose post process on
  52110. */
  52111. dispose(camera: Camera): void;
  52112. }
  52113. }
  52114. declare module BABYLON {
  52115. /** @hidden */
  52116. export var sharpenPixelShader: {
  52117. name: string;
  52118. shader: string;
  52119. };
  52120. }
  52121. declare module BABYLON {
  52122. /**
  52123. * The SharpenPostProcess applies a sharpen kernel to every pixel
  52124. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52125. */
  52126. export class SharpenPostProcess extends PostProcess {
  52127. /**
  52128. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  52129. */
  52130. colorAmount: number;
  52131. /**
  52132. * How much sharpness should be applied (default: 0.3)
  52133. */
  52134. edgeAmount: number;
  52135. /**
  52136. * Creates a new instance ConvolutionPostProcess
  52137. * @param name The name of the effect.
  52138. * @param options The required width/height ratio to downsize to before computing the render pass.
  52139. * @param camera The camera to apply the render pass to.
  52140. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52141. * @param engine The engine which the post process will be applied. (default: current engine)
  52142. * @param reusable If the post process can be reused on the same frame. (default: false)
  52143. * @param textureType Type of textures used when performing the post process. (default: 0)
  52144. * @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)
  52145. */
  52146. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52147. }
  52148. }
  52149. declare module BABYLON {
  52150. /**
  52151. * PostProcessRenderPipeline
  52152. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52153. */
  52154. export class PostProcessRenderPipeline {
  52155. private engine;
  52156. private _renderEffects;
  52157. private _renderEffectsForIsolatedPass;
  52158. /**
  52159. * List of inspectable custom properties (used by the Inspector)
  52160. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  52161. */
  52162. inspectableCustomProperties: IInspectable[];
  52163. /**
  52164. * @hidden
  52165. */
  52166. protected _cameras: Camera[];
  52167. /** @hidden */ name: string;
  52168. /**
  52169. * Gets pipeline name
  52170. */
  52171. readonly name: string;
  52172. /**
  52173. * Initializes a PostProcessRenderPipeline
  52174. * @param engine engine to add the pipeline to
  52175. * @param name name of the pipeline
  52176. */
  52177. constructor(engine: Engine, name: string);
  52178. /**
  52179. * Gets the class name
  52180. * @returns "PostProcessRenderPipeline"
  52181. */
  52182. getClassName(): string;
  52183. /**
  52184. * If all the render effects in the pipeline are supported
  52185. */
  52186. readonly isSupported: boolean;
  52187. /**
  52188. * Adds an effect to the pipeline
  52189. * @param renderEffect the effect to add
  52190. */
  52191. addEffect(renderEffect: PostProcessRenderEffect): void;
  52192. /** @hidden */ rebuild(): void;
  52193. /** @hidden */ enableEffect(renderEffectName: string, cameras: Camera): void;
  52194. /** @hidden */ enableEffect(renderEffectName: string, cameras: Camera[]): void;
  52195. /** @hidden */ disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52196. /** @hidden */ disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52197. /** @hidden */ attachCameras(cameras: Camera, unique: boolean): void;
  52198. /** @hidden */ attachCameras(cameras: Camera[], unique: boolean): void;
  52199. /** @hidden */ detachCameras(cameras: Camera): void;
  52200. /** @hidden */ detachCameras(cameras: Nullable<Camera[]>): void;
  52201. /** @hidden */ update(): void;
  52202. /** @hidden */ reset(): void;
  52203. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  52204. /**
  52205. * Disposes of the pipeline
  52206. */
  52207. dispose(): void;
  52208. }
  52209. }
  52210. declare module BABYLON {
  52211. /**
  52212. * PostProcessRenderPipelineManager class
  52213. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52214. */
  52215. export class PostProcessRenderPipelineManager {
  52216. private _renderPipelines;
  52217. /**
  52218. * Initializes a PostProcessRenderPipelineManager
  52219. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52220. */
  52221. constructor();
  52222. /**
  52223. * Gets the list of supported render pipelines
  52224. */
  52225. readonly supportedPipelines: PostProcessRenderPipeline[];
  52226. /**
  52227. * Adds a pipeline to the manager
  52228. * @param renderPipeline The pipeline to add
  52229. */
  52230. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  52231. /**
  52232. * Attaches a camera to the pipeline
  52233. * @param renderPipelineName The name of the pipeline to attach to
  52234. * @param cameras the camera to attach
  52235. * @param unique if the camera can be attached multiple times to the pipeline
  52236. */
  52237. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  52238. /**
  52239. * Detaches a camera from the pipeline
  52240. * @param renderPipelineName The name of the pipeline to detach from
  52241. * @param cameras the camera to detach
  52242. */
  52243. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  52244. /**
  52245. * Enables an effect by name on a pipeline
  52246. * @param renderPipelineName the name of the pipeline to enable the effect in
  52247. * @param renderEffectName the name of the effect to enable
  52248. * @param cameras the cameras that the effect should be enabled on
  52249. */
  52250. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  52251. /**
  52252. * Disables an effect by name on a pipeline
  52253. * @param renderPipelineName the name of the pipeline to disable the effect in
  52254. * @param renderEffectName the name of the effect to disable
  52255. * @param cameras the cameras that the effect should be disabled on
  52256. */
  52257. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  52258. /**
  52259. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  52260. */
  52261. update(): void;
  52262. /** @hidden */ rebuild(): void;
  52263. /**
  52264. * Disposes of the manager and pipelines
  52265. */
  52266. dispose(): void;
  52267. }
  52268. }
  52269. declare module BABYLON {
  52270. interface Scene {
  52271. /** @hidden (Backing field) */ postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  52272. /**
  52273. * Gets the postprocess render pipeline manager
  52274. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52275. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52276. */
  52277. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  52278. }
  52279. /**
  52280. * Defines the Render Pipeline scene component responsible to rendering pipelines
  52281. */
  52282. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  52283. /**
  52284. * The component name helpfull to identify the component in the list of scene components.
  52285. */
  52286. readonly name: string;
  52287. /**
  52288. * The scene the component belongs to.
  52289. */
  52290. scene: Scene;
  52291. /**
  52292. * Creates a new instance of the component for the given scene
  52293. * @param scene Defines the scene to register the component in
  52294. */
  52295. constructor(scene: Scene);
  52296. /**
  52297. * Registers the component in a given scene
  52298. */
  52299. register(): void;
  52300. /**
  52301. * Rebuilds the elements related to this component in case of
  52302. * context lost for instance.
  52303. */
  52304. rebuild(): void;
  52305. /**
  52306. * Disposes the component and the associated ressources
  52307. */
  52308. dispose(): void;
  52309. private _gatherRenderTargets;
  52310. }
  52311. }
  52312. declare module BABYLON {
  52313. /**
  52314. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  52315. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52316. */
  52317. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  52318. private _scene;
  52319. private _camerasToBeAttached;
  52320. /**
  52321. * ID of the sharpen post process,
  52322. */
  52323. private readonly SharpenPostProcessId;
  52324. /**
  52325. * @ignore
  52326. * ID of the image processing post process;
  52327. */
  52328. readonly ImageProcessingPostProcessId: string;
  52329. /**
  52330. * @ignore
  52331. * ID of the Fast Approximate Anti-Aliasing post process;
  52332. */
  52333. readonly FxaaPostProcessId: string;
  52334. /**
  52335. * ID of the chromatic aberration post process,
  52336. */
  52337. private readonly ChromaticAberrationPostProcessId;
  52338. /**
  52339. * ID of the grain post process
  52340. */
  52341. private readonly GrainPostProcessId;
  52342. /**
  52343. * Sharpen post process which will apply a sharpen convolution to enhance edges
  52344. */
  52345. sharpen: SharpenPostProcess;
  52346. private _sharpenEffect;
  52347. private bloom;
  52348. /**
  52349. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  52350. */
  52351. depthOfField: DepthOfFieldEffect;
  52352. /**
  52353. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  52354. */
  52355. fxaa: FxaaPostProcess;
  52356. /**
  52357. * Image post processing pass used to perform operations such as tone mapping or color grading.
  52358. */
  52359. imageProcessing: ImageProcessingPostProcess;
  52360. /**
  52361. * Chromatic aberration post process which will shift rgb colors in the image
  52362. */
  52363. chromaticAberration: ChromaticAberrationPostProcess;
  52364. private _chromaticAberrationEffect;
  52365. /**
  52366. * Grain post process which add noise to the image
  52367. */
  52368. grain: GrainPostProcess;
  52369. private _grainEffect;
  52370. /**
  52371. * Glow post process which adds a glow to emissive areas of the image
  52372. */
  52373. private _glowLayer;
  52374. /**
  52375. * Animations which can be used to tweak settings over a period of time
  52376. */
  52377. animations: Animation[];
  52378. private _imageProcessingConfigurationObserver;
  52379. private _sharpenEnabled;
  52380. private _bloomEnabled;
  52381. private _depthOfFieldEnabled;
  52382. private _depthOfFieldBlurLevel;
  52383. private _fxaaEnabled;
  52384. private _imageProcessingEnabled;
  52385. private _defaultPipelineTextureType;
  52386. private _bloomScale;
  52387. private _chromaticAberrationEnabled;
  52388. private _grainEnabled;
  52389. private _buildAllowed;
  52390. /**
  52391. * Gets active scene
  52392. */
  52393. readonly scene: Scene;
  52394. /**
  52395. * Enable or disable the sharpen process from the pipeline
  52396. */
  52397. sharpenEnabled: boolean;
  52398. private _resizeObserver;
  52399. private _hardwareScaleLevel;
  52400. private _bloomKernel;
  52401. /**
  52402. * Specifies the size of the bloom blur kernel, relative to the final output size
  52403. */
  52404. bloomKernel: number;
  52405. /**
  52406. * Specifies the weight of the bloom in the final rendering
  52407. */
  52408. private _bloomWeight;
  52409. /**
  52410. * Specifies the luma threshold for the area that will be blurred by the bloom
  52411. */
  52412. private _bloomThreshold;
  52413. private _hdr;
  52414. /**
  52415. * The strength of the bloom.
  52416. */
  52417. bloomWeight: number;
  52418. /**
  52419. * The strength of the bloom.
  52420. */
  52421. bloomThreshold: number;
  52422. /**
  52423. * The scale of the bloom, lower value will provide better performance.
  52424. */
  52425. bloomScale: number;
  52426. /**
  52427. * Enable or disable the bloom from the pipeline
  52428. */
  52429. bloomEnabled: boolean;
  52430. private _rebuildBloom;
  52431. /**
  52432. * If the depth of field is enabled.
  52433. */
  52434. depthOfFieldEnabled: boolean;
  52435. /**
  52436. * Blur level of the depth of field effect. (Higher blur will effect performance)
  52437. */
  52438. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  52439. /**
  52440. * If the anti aliasing is enabled.
  52441. */
  52442. fxaaEnabled: boolean;
  52443. private _samples;
  52444. /**
  52445. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  52446. */
  52447. samples: number;
  52448. /**
  52449. * If image processing is enabled.
  52450. */
  52451. imageProcessingEnabled: boolean;
  52452. /**
  52453. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  52454. */
  52455. glowLayerEnabled: boolean;
  52456. /**
  52457. * Enable or disable the chromaticAberration process from the pipeline
  52458. */
  52459. chromaticAberrationEnabled: boolean;
  52460. /**
  52461. * Enable or disable the grain process from the pipeline
  52462. */
  52463. grainEnabled: boolean;
  52464. /**
  52465. * @constructor
  52466. * @param name - The rendering pipeline name (default: "")
  52467. * @param hdr - If high dynamic range textures should be used (default: true)
  52468. * @param scene - The scene linked to this pipeline (default: the last created scene)
  52469. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  52470. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  52471. */
  52472. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  52473. /**
  52474. * Get the class name
  52475. * @returns "DefaultRenderingPipeline"
  52476. */
  52477. getClassName(): string;
  52478. /**
  52479. * Force the compilation of the entire pipeline.
  52480. */
  52481. prepare(): void;
  52482. private _hasCleared;
  52483. private _prevPostProcess;
  52484. private _prevPrevPostProcess;
  52485. private _setAutoClearAndTextureSharing;
  52486. private _depthOfFieldSceneObserver;
  52487. private _buildPipeline;
  52488. private _disposePostProcesses;
  52489. /**
  52490. * Adds a camera to the pipeline
  52491. * @param camera the camera to be added
  52492. */
  52493. addCamera(camera: Camera): void;
  52494. /**
  52495. * Removes a camera from the pipeline
  52496. * @param camera the camera to remove
  52497. */
  52498. removeCamera(camera: Camera): void;
  52499. /**
  52500. * Dispose of the pipeline and stop all post processes
  52501. */
  52502. dispose(): void;
  52503. /**
  52504. * Serialize the rendering pipeline (Used when exporting)
  52505. * @returns the serialized object
  52506. */
  52507. serialize(): any;
  52508. /**
  52509. * Parse the serialized pipeline
  52510. * @param source Source pipeline.
  52511. * @param scene The scene to load the pipeline to.
  52512. * @param rootUrl The URL of the serialized pipeline.
  52513. * @returns An instantiated pipeline from the serialized object.
  52514. */
  52515. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  52516. }
  52517. }
  52518. declare module BABYLON {
  52519. /** @hidden */
  52520. export var lensHighlightsPixelShader: {
  52521. name: string;
  52522. shader: string;
  52523. };
  52524. }
  52525. declare module BABYLON {
  52526. /** @hidden */
  52527. export var depthOfFieldPixelShader: {
  52528. name: string;
  52529. shader: string;
  52530. };
  52531. }
  52532. declare module BABYLON {
  52533. /**
  52534. * BABYLON.JS Chromatic Aberration GLSL Shader
  52535. * Author: Olivier Guyot
  52536. * Separates very slightly R, G and B colors on the edges of the screen
  52537. * Inspired by Francois Tarlier & Martins Upitis
  52538. */
  52539. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  52540. /**
  52541. * @ignore
  52542. * The chromatic aberration PostProcess id in the pipeline
  52543. */
  52544. LensChromaticAberrationEffect: string;
  52545. /**
  52546. * @ignore
  52547. * The highlights enhancing PostProcess id in the pipeline
  52548. */
  52549. HighlightsEnhancingEffect: string;
  52550. /**
  52551. * @ignore
  52552. * The depth-of-field PostProcess id in the pipeline
  52553. */
  52554. LensDepthOfFieldEffect: string;
  52555. private _scene;
  52556. private _depthTexture;
  52557. private _grainTexture;
  52558. private _chromaticAberrationPostProcess;
  52559. private _highlightsPostProcess;
  52560. private _depthOfFieldPostProcess;
  52561. private _edgeBlur;
  52562. private _grainAmount;
  52563. private _chromaticAberration;
  52564. private _distortion;
  52565. private _highlightsGain;
  52566. private _highlightsThreshold;
  52567. private _dofDistance;
  52568. private _dofAperture;
  52569. private _dofDarken;
  52570. private _dofPentagon;
  52571. private _blurNoise;
  52572. /**
  52573. * @constructor
  52574. *
  52575. * Effect parameters are as follow:
  52576. * {
  52577. * chromatic_aberration: number; // from 0 to x (1 for realism)
  52578. * edge_blur: number; // from 0 to x (1 for realism)
  52579. * distortion: number; // from 0 to x (1 for realism)
  52580. * grain_amount: number; // from 0 to 1
  52581. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  52582. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  52583. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  52584. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  52585. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  52586. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  52587. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  52588. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  52589. * }
  52590. * Note: if an effect parameter is unset, effect is disabled
  52591. *
  52592. * @param name The rendering pipeline name
  52593. * @param parameters - An object containing all parameters (see above)
  52594. * @param scene The scene linked to this pipeline
  52595. * @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)
  52596. * @param cameras The array of cameras that the rendering pipeline will be attached to
  52597. */
  52598. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  52599. /**
  52600. * Get the class name
  52601. * @returns "LensRenderingPipeline"
  52602. */
  52603. getClassName(): string;
  52604. /**
  52605. * Gets associated scene
  52606. */
  52607. readonly scene: Scene;
  52608. /**
  52609. * Gets or sets the edge blur
  52610. */
  52611. edgeBlur: number;
  52612. /**
  52613. * Gets or sets the grain amount
  52614. */
  52615. grainAmount: number;
  52616. /**
  52617. * Gets or sets the chromatic aberration amount
  52618. */
  52619. chromaticAberration: number;
  52620. /**
  52621. * Gets or sets the depth of field aperture
  52622. */
  52623. dofAperture: number;
  52624. /**
  52625. * Gets or sets the edge distortion
  52626. */
  52627. edgeDistortion: number;
  52628. /**
  52629. * Gets or sets the depth of field distortion
  52630. */
  52631. dofDistortion: number;
  52632. /**
  52633. * Gets or sets the darken out of focus amount
  52634. */
  52635. darkenOutOfFocus: number;
  52636. /**
  52637. * Gets or sets a boolean indicating if blur noise is enabled
  52638. */
  52639. blurNoise: boolean;
  52640. /**
  52641. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  52642. */
  52643. pentagonBokeh: boolean;
  52644. /**
  52645. * Gets or sets the highlight grain amount
  52646. */
  52647. highlightsGain: number;
  52648. /**
  52649. * Gets or sets the highlight threshold
  52650. */
  52651. highlightsThreshold: number;
  52652. /**
  52653. * Sets the amount of blur at the edges
  52654. * @param amount blur amount
  52655. */
  52656. setEdgeBlur(amount: number): void;
  52657. /**
  52658. * Sets edge blur to 0
  52659. */
  52660. disableEdgeBlur(): void;
  52661. /**
  52662. * Sets the amout of grain
  52663. * @param amount Amount of grain
  52664. */
  52665. setGrainAmount(amount: number): void;
  52666. /**
  52667. * Set grain amount to 0
  52668. */
  52669. disableGrain(): void;
  52670. /**
  52671. * Sets the chromatic aberration amount
  52672. * @param amount amount of chromatic aberration
  52673. */
  52674. setChromaticAberration(amount: number): void;
  52675. /**
  52676. * Sets chromatic aberration amount to 0
  52677. */
  52678. disableChromaticAberration(): void;
  52679. /**
  52680. * Sets the EdgeDistortion amount
  52681. * @param amount amount of EdgeDistortion
  52682. */
  52683. setEdgeDistortion(amount: number): void;
  52684. /**
  52685. * Sets edge distortion to 0
  52686. */
  52687. disableEdgeDistortion(): void;
  52688. /**
  52689. * Sets the FocusDistance amount
  52690. * @param amount amount of FocusDistance
  52691. */
  52692. setFocusDistance(amount: number): void;
  52693. /**
  52694. * Disables depth of field
  52695. */
  52696. disableDepthOfField(): void;
  52697. /**
  52698. * Sets the Aperture amount
  52699. * @param amount amount of Aperture
  52700. */
  52701. setAperture(amount: number): void;
  52702. /**
  52703. * Sets the DarkenOutOfFocus amount
  52704. * @param amount amount of DarkenOutOfFocus
  52705. */
  52706. setDarkenOutOfFocus(amount: number): void;
  52707. private _pentagonBokehIsEnabled;
  52708. /**
  52709. * Creates a pentagon bokeh effect
  52710. */
  52711. enablePentagonBokeh(): void;
  52712. /**
  52713. * Disables the pentagon bokeh effect
  52714. */
  52715. disablePentagonBokeh(): void;
  52716. /**
  52717. * Enables noise blur
  52718. */
  52719. enableNoiseBlur(): void;
  52720. /**
  52721. * Disables noise blur
  52722. */
  52723. disableNoiseBlur(): void;
  52724. /**
  52725. * Sets the HighlightsGain amount
  52726. * @param amount amount of HighlightsGain
  52727. */
  52728. setHighlightsGain(amount: number): void;
  52729. /**
  52730. * Sets the HighlightsThreshold amount
  52731. * @param amount amount of HighlightsThreshold
  52732. */
  52733. setHighlightsThreshold(amount: number): void;
  52734. /**
  52735. * Disables highlights
  52736. */
  52737. disableHighlights(): void;
  52738. /**
  52739. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  52740. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  52741. */
  52742. dispose(disableDepthRender?: boolean): void;
  52743. private _createChromaticAberrationPostProcess;
  52744. private _createHighlightsPostProcess;
  52745. private _createDepthOfFieldPostProcess;
  52746. private _createGrainTexture;
  52747. }
  52748. }
  52749. declare module BABYLON {
  52750. /** @hidden */
  52751. export var ssao2PixelShader: {
  52752. name: string;
  52753. shader: string;
  52754. };
  52755. }
  52756. declare module BABYLON {
  52757. /** @hidden */
  52758. export var ssaoCombinePixelShader: {
  52759. name: string;
  52760. shader: string;
  52761. };
  52762. }
  52763. declare module BABYLON {
  52764. /**
  52765. * Render pipeline to produce ssao effect
  52766. */
  52767. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  52768. /**
  52769. * @ignore
  52770. * The PassPostProcess id in the pipeline that contains the original scene color
  52771. */
  52772. SSAOOriginalSceneColorEffect: string;
  52773. /**
  52774. * @ignore
  52775. * The SSAO PostProcess id in the pipeline
  52776. */
  52777. SSAORenderEffect: string;
  52778. /**
  52779. * @ignore
  52780. * The horizontal blur PostProcess id in the pipeline
  52781. */
  52782. SSAOBlurHRenderEffect: string;
  52783. /**
  52784. * @ignore
  52785. * The vertical blur PostProcess id in the pipeline
  52786. */
  52787. SSAOBlurVRenderEffect: string;
  52788. /**
  52789. * @ignore
  52790. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  52791. */
  52792. SSAOCombineRenderEffect: string;
  52793. /**
  52794. * The output strength of the SSAO post-process. Default value is 1.0.
  52795. */
  52796. totalStrength: number;
  52797. /**
  52798. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  52799. */
  52800. maxZ: number;
  52801. /**
  52802. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  52803. */
  52804. minZAspect: number;
  52805. private _samples;
  52806. /**
  52807. * Number of samples used for the SSAO calculations. Default value is 8
  52808. */
  52809. samples: number;
  52810. private _textureSamples;
  52811. /**
  52812. * Number of samples to use for antialiasing
  52813. */
  52814. textureSamples: number;
  52815. /**
  52816. * Ratio object used for SSAO ratio and blur ratio
  52817. */
  52818. private _ratio;
  52819. /**
  52820. * Dynamically generated sphere sampler.
  52821. */
  52822. private _sampleSphere;
  52823. /**
  52824. * Blur filter offsets
  52825. */
  52826. private _samplerOffsets;
  52827. private _expensiveBlur;
  52828. /**
  52829. * If bilateral blur should be used
  52830. */
  52831. expensiveBlur: boolean;
  52832. /**
  52833. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  52834. */
  52835. radius: number;
  52836. /**
  52837. * The base color of the SSAO post-process
  52838. * The final result is "base + ssao" between [0, 1]
  52839. */
  52840. base: number;
  52841. /**
  52842. * Support test.
  52843. */
  52844. static readonly IsSupported: boolean;
  52845. private _scene;
  52846. private _depthTexture;
  52847. private _normalTexture;
  52848. private _randomTexture;
  52849. private _originalColorPostProcess;
  52850. private _ssaoPostProcess;
  52851. private _blurHPostProcess;
  52852. private _blurVPostProcess;
  52853. private _ssaoCombinePostProcess;
  52854. private _firstUpdate;
  52855. /**
  52856. * Gets active scene
  52857. */
  52858. readonly scene: Scene;
  52859. /**
  52860. * @constructor
  52861. * @param name The rendering pipeline name
  52862. * @param scene The scene linked to this pipeline
  52863. * @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 }
  52864. * @param cameras The array of cameras that the rendering pipeline will be attached to
  52865. */
  52866. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  52867. /**
  52868. * Get the class name
  52869. * @returns "SSAO2RenderingPipeline"
  52870. */
  52871. getClassName(): string;
  52872. /**
  52873. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  52874. */
  52875. dispose(disableGeometryBufferRenderer?: boolean): void;
  52876. private _createBlurPostProcess;
  52877. /** @hidden */ rebuild(): void;
  52878. private _bits;
  52879. private _radicalInverse_VdC;
  52880. private _hammersley;
  52881. private _hemisphereSample_uniform;
  52882. private _generateHemisphere;
  52883. private _createSSAOPostProcess;
  52884. private _createSSAOCombinePostProcess;
  52885. private _createRandomTexture;
  52886. /**
  52887. * Serialize the rendering pipeline (Used when exporting)
  52888. * @returns the serialized object
  52889. */
  52890. serialize(): any;
  52891. /**
  52892. * Parse the serialized pipeline
  52893. * @param source Source pipeline.
  52894. * @param scene The scene to load the pipeline to.
  52895. * @param rootUrl The URL of the serialized pipeline.
  52896. * @returns An instantiated pipeline from the serialized object.
  52897. */
  52898. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  52899. }
  52900. }
  52901. declare module BABYLON {
  52902. /** @hidden */
  52903. export var ssaoPixelShader: {
  52904. name: string;
  52905. shader: string;
  52906. };
  52907. }
  52908. declare module BABYLON {
  52909. /**
  52910. * Render pipeline to produce ssao effect
  52911. */
  52912. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  52913. /**
  52914. * @ignore
  52915. * The PassPostProcess id in the pipeline that contains the original scene color
  52916. */
  52917. SSAOOriginalSceneColorEffect: string;
  52918. /**
  52919. * @ignore
  52920. * The SSAO PostProcess id in the pipeline
  52921. */
  52922. SSAORenderEffect: string;
  52923. /**
  52924. * @ignore
  52925. * The horizontal blur PostProcess id in the pipeline
  52926. */
  52927. SSAOBlurHRenderEffect: string;
  52928. /**
  52929. * @ignore
  52930. * The vertical blur PostProcess id in the pipeline
  52931. */
  52932. SSAOBlurVRenderEffect: string;
  52933. /**
  52934. * @ignore
  52935. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  52936. */
  52937. SSAOCombineRenderEffect: string;
  52938. /**
  52939. * The output strength of the SSAO post-process. Default value is 1.0.
  52940. */
  52941. totalStrength: number;
  52942. /**
  52943. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  52944. */
  52945. radius: number;
  52946. /**
  52947. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  52948. * Must not be equal to fallOff and superior to fallOff.
  52949. * Default value is 0.0075
  52950. */
  52951. area: number;
  52952. /**
  52953. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  52954. * Must not be equal to area and inferior to area.
  52955. * Default value is 0.000001
  52956. */
  52957. fallOff: number;
  52958. /**
  52959. * The base color of the SSAO post-process
  52960. * The final result is "base + ssao" between [0, 1]
  52961. */
  52962. base: number;
  52963. private _scene;
  52964. private _depthTexture;
  52965. private _randomTexture;
  52966. private _originalColorPostProcess;
  52967. private _ssaoPostProcess;
  52968. private _blurHPostProcess;
  52969. private _blurVPostProcess;
  52970. private _ssaoCombinePostProcess;
  52971. private _firstUpdate;
  52972. /**
  52973. * Gets active scene
  52974. */
  52975. readonly scene: Scene;
  52976. /**
  52977. * @constructor
  52978. * @param name - The rendering pipeline name
  52979. * @param scene - The scene linked to this pipeline
  52980. * @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 }
  52981. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  52982. */
  52983. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  52984. /**
  52985. * Get the class name
  52986. * @returns "SSAORenderingPipeline"
  52987. */
  52988. getClassName(): string;
  52989. /**
  52990. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  52991. */
  52992. dispose(disableDepthRender?: boolean): void;
  52993. private _createBlurPostProcess;
  52994. /** @hidden */ rebuild(): void;
  52995. private _createSSAOPostProcess;
  52996. private _createSSAOCombinePostProcess;
  52997. private _createRandomTexture;
  52998. }
  52999. }
  53000. declare module BABYLON {
  53001. /** @hidden */
  53002. export var standardPixelShader: {
  53003. name: string;
  53004. shader: string;
  53005. };
  53006. }
  53007. declare module BABYLON {
  53008. /**
  53009. * Standard rendering pipeline
  53010. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53011. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  53012. */
  53013. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53014. /**
  53015. * Public members
  53016. */
  53017. /**
  53018. * Post-process which contains the original scene color before the pipeline applies all the effects
  53019. */
  53020. originalPostProcess: Nullable<PostProcess>;
  53021. /**
  53022. * Post-process used to down scale an image x4
  53023. */
  53024. downSampleX4PostProcess: Nullable<PostProcess>;
  53025. /**
  53026. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  53027. */
  53028. brightPassPostProcess: Nullable<PostProcess>;
  53029. /**
  53030. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  53031. */
  53032. blurHPostProcesses: PostProcess[];
  53033. /**
  53034. * Post-process array storing all the vertical blur post-processes used by the pipeline
  53035. */
  53036. blurVPostProcesses: PostProcess[];
  53037. /**
  53038. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  53039. */
  53040. textureAdderPostProcess: Nullable<PostProcess>;
  53041. /**
  53042. * Post-process used to create volumetric lighting effect
  53043. */
  53044. volumetricLightPostProcess: Nullable<PostProcess>;
  53045. /**
  53046. * Post-process used to smooth the previous volumetric light post-process on the X axis
  53047. */
  53048. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  53049. /**
  53050. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  53051. */
  53052. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  53053. /**
  53054. * Post-process used to merge the volumetric light effect and the real scene color
  53055. */
  53056. volumetricLightMergePostProces: Nullable<PostProcess>;
  53057. /**
  53058. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  53059. */
  53060. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  53061. /**
  53062. * Base post-process used to calculate the average luminance of the final image for HDR
  53063. */
  53064. luminancePostProcess: Nullable<PostProcess>;
  53065. /**
  53066. * Post-processes used to create down sample post-processes in order to get
  53067. * the average luminance of the final image for HDR
  53068. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  53069. */
  53070. luminanceDownSamplePostProcesses: PostProcess[];
  53071. /**
  53072. * Post-process used to create a HDR effect (light adaptation)
  53073. */
  53074. hdrPostProcess: Nullable<PostProcess>;
  53075. /**
  53076. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  53077. */
  53078. textureAdderFinalPostProcess: Nullable<PostProcess>;
  53079. /**
  53080. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  53081. */
  53082. lensFlareFinalPostProcess: Nullable<PostProcess>;
  53083. /**
  53084. * Post-process used to merge the final HDR post-process and the real scene color
  53085. */
  53086. hdrFinalPostProcess: Nullable<PostProcess>;
  53087. /**
  53088. * Post-process used to create a lens flare effect
  53089. */
  53090. lensFlarePostProcess: Nullable<PostProcess>;
  53091. /**
  53092. * Post-process that merges the result of the lens flare post-process and the real scene color
  53093. */
  53094. lensFlareComposePostProcess: Nullable<PostProcess>;
  53095. /**
  53096. * Post-process used to create a motion blur effect
  53097. */
  53098. motionBlurPostProcess: Nullable<PostProcess>;
  53099. /**
  53100. * Post-process used to create a depth of field effect
  53101. */
  53102. depthOfFieldPostProcess: Nullable<PostProcess>;
  53103. /**
  53104. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53105. */
  53106. fxaaPostProcess: Nullable<FxaaPostProcess>;
  53107. /**
  53108. * Represents the brightness threshold in order to configure the illuminated surfaces
  53109. */
  53110. brightThreshold: number;
  53111. /**
  53112. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  53113. */
  53114. blurWidth: number;
  53115. /**
  53116. * Sets if the blur for highlighted surfaces must be only horizontal
  53117. */
  53118. horizontalBlur: boolean;
  53119. /**
  53120. * Gets the overall exposure used by the pipeline
  53121. */
  53122. /**
  53123. * Sets the overall exposure used by the pipeline
  53124. */
  53125. exposure: number;
  53126. /**
  53127. * Texture used typically to simulate "dirty" on camera lens
  53128. */
  53129. lensTexture: Nullable<Texture>;
  53130. /**
  53131. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  53132. */
  53133. volumetricLightCoefficient: number;
  53134. /**
  53135. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  53136. */
  53137. volumetricLightPower: number;
  53138. /**
  53139. * Used the set the blur intensity to smooth the volumetric lights
  53140. */
  53141. volumetricLightBlurScale: number;
  53142. /**
  53143. * Light (spot or directional) used to generate the volumetric lights rays
  53144. * The source light must have a shadow generate so the pipeline can get its
  53145. * depth map
  53146. */
  53147. sourceLight: Nullable<SpotLight | DirectionalLight>;
  53148. /**
  53149. * For eye adaptation, represents the minimum luminance the eye can see
  53150. */
  53151. hdrMinimumLuminance: number;
  53152. /**
  53153. * For eye adaptation, represents the decrease luminance speed
  53154. */
  53155. hdrDecreaseRate: number;
  53156. /**
  53157. * For eye adaptation, represents the increase luminance speed
  53158. */
  53159. hdrIncreaseRate: number;
  53160. /**
  53161. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  53162. */
  53163. /**
  53164. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  53165. */
  53166. hdrAutoExposure: boolean;
  53167. /**
  53168. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  53169. */
  53170. lensColorTexture: Nullable<Texture>;
  53171. /**
  53172. * The overall strengh for the lens flare effect
  53173. */
  53174. lensFlareStrength: number;
  53175. /**
  53176. * Dispersion coefficient for lens flare ghosts
  53177. */
  53178. lensFlareGhostDispersal: number;
  53179. /**
  53180. * Main lens flare halo width
  53181. */
  53182. lensFlareHaloWidth: number;
  53183. /**
  53184. * Based on the lens distortion effect, defines how much the lens flare result
  53185. * is distorted
  53186. */
  53187. lensFlareDistortionStrength: number;
  53188. /**
  53189. * Lens star texture must be used to simulate rays on the flares and is available
  53190. * in the documentation
  53191. */
  53192. lensStarTexture: Nullable<Texture>;
  53193. /**
  53194. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  53195. * flare effect by taking account of the dirt texture
  53196. */
  53197. lensFlareDirtTexture: Nullable<Texture>;
  53198. /**
  53199. * Represents the focal length for the depth of field effect
  53200. */
  53201. depthOfFieldDistance: number;
  53202. /**
  53203. * Represents the blur intensity for the blurred part of the depth of field effect
  53204. */
  53205. depthOfFieldBlurWidth: number;
  53206. /**
  53207. * For motion blur, defines how much the image is blurred by the movement
  53208. */
  53209. motionStrength: number;
  53210. /**
  53211. * List of animations for the pipeline (IAnimatable implementation)
  53212. */
  53213. animations: Animation[];
  53214. /**
  53215. * Private members
  53216. */
  53217. private _scene;
  53218. private _currentDepthOfFieldSource;
  53219. private _basePostProcess;
  53220. private _fixedExposure;
  53221. private _currentExposure;
  53222. private _hdrAutoExposure;
  53223. private _hdrCurrentLuminance;
  53224. private _floatTextureType;
  53225. private _ratio;
  53226. private _bloomEnabled;
  53227. private _depthOfFieldEnabled;
  53228. private _vlsEnabled;
  53229. private _lensFlareEnabled;
  53230. private _hdrEnabled;
  53231. private _motionBlurEnabled;
  53232. private _fxaaEnabled;
  53233. private _motionBlurSamples;
  53234. private _volumetricLightStepsCount;
  53235. private _samples;
  53236. /**
  53237. * @ignore
  53238. * Specifies if the bloom pipeline is enabled
  53239. */
  53240. BloomEnabled: boolean;
  53241. /**
  53242. * @ignore
  53243. * Specifies if the depth of field pipeline is enabed
  53244. */
  53245. DepthOfFieldEnabled: boolean;
  53246. /**
  53247. * @ignore
  53248. * Specifies if the lens flare pipeline is enabed
  53249. */
  53250. LensFlareEnabled: boolean;
  53251. /**
  53252. * @ignore
  53253. * Specifies if the HDR pipeline is enabled
  53254. */
  53255. HDREnabled: boolean;
  53256. /**
  53257. * @ignore
  53258. * Specifies if the volumetric lights scattering effect is enabled
  53259. */
  53260. VLSEnabled: boolean;
  53261. /**
  53262. * @ignore
  53263. * Specifies if the motion blur effect is enabled
  53264. */
  53265. MotionBlurEnabled: boolean;
  53266. /**
  53267. * Specifies if anti-aliasing is enabled
  53268. */
  53269. fxaaEnabled: boolean;
  53270. /**
  53271. * Specifies the number of steps used to calculate the volumetric lights
  53272. * Typically in interval [50, 200]
  53273. */
  53274. volumetricLightStepsCount: number;
  53275. /**
  53276. * Specifies the number of samples used for the motion blur effect
  53277. * Typically in interval [16, 64]
  53278. */
  53279. motionBlurSamples: number;
  53280. /**
  53281. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53282. */
  53283. samples: number;
  53284. /**
  53285. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53286. * @constructor
  53287. * @param name The rendering pipeline name
  53288. * @param scene The scene linked to this pipeline
  53289. * @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)
  53290. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  53291. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53292. */
  53293. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  53294. private _buildPipeline;
  53295. private _createDownSampleX4PostProcess;
  53296. private _createBrightPassPostProcess;
  53297. private _createBlurPostProcesses;
  53298. private _createTextureAdderPostProcess;
  53299. private _createVolumetricLightPostProcess;
  53300. private _createLuminancePostProcesses;
  53301. private _createHdrPostProcess;
  53302. private _createLensFlarePostProcess;
  53303. private _createDepthOfFieldPostProcess;
  53304. private _createMotionBlurPostProcess;
  53305. private _getDepthTexture;
  53306. private _disposePostProcesses;
  53307. /**
  53308. * Dispose of the pipeline and stop all post processes
  53309. */
  53310. dispose(): void;
  53311. /**
  53312. * Serialize the rendering pipeline (Used when exporting)
  53313. * @returns the serialized object
  53314. */
  53315. serialize(): any;
  53316. /**
  53317. * Parse the serialized pipeline
  53318. * @param source Source pipeline.
  53319. * @param scene The scene to load the pipeline to.
  53320. * @param rootUrl The URL of the serialized pipeline.
  53321. * @returns An instantiated pipeline from the serialized object.
  53322. */
  53323. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  53324. /**
  53325. * Luminance steps
  53326. */
  53327. static LuminanceSteps: number;
  53328. }
  53329. }
  53330. declare module BABYLON {
  53331. /** @hidden */
  53332. export var tonemapPixelShader: {
  53333. name: string;
  53334. shader: string;
  53335. };
  53336. }
  53337. declare module BABYLON {
  53338. /** Defines operator used for tonemapping */
  53339. export enum TonemappingOperator {
  53340. /** Hable */
  53341. Hable = 0,
  53342. /** Reinhard */
  53343. Reinhard = 1,
  53344. /** HejiDawson */
  53345. HejiDawson = 2,
  53346. /** Photographic */
  53347. Photographic = 3
  53348. }
  53349. /**
  53350. * Defines a post process to apply tone mapping
  53351. */
  53352. export class TonemapPostProcess extends PostProcess {
  53353. private _operator;
  53354. /** Defines the required exposure adjustement */
  53355. exposureAdjustment: number;
  53356. /**
  53357. * Creates a new TonemapPostProcess
  53358. * @param name defines the name of the postprocess
  53359. * @param _operator defines the operator to use
  53360. * @param exposureAdjustment defines the required exposure adjustement
  53361. * @param camera defines the camera to use (can be null)
  53362. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  53363. * @param engine defines the hosting engine (can be ignore if camera is set)
  53364. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53365. */
  53366. constructor(name: string, _operator: TonemappingOperator,
  53367. /** Defines the required exposure adjustement */
  53368. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  53369. }
  53370. }
  53371. declare module BABYLON {
  53372. /** @hidden */
  53373. export var depthVertexShader: {
  53374. name: string;
  53375. shader: string;
  53376. };
  53377. }
  53378. declare module BABYLON {
  53379. /** @hidden */
  53380. export var volumetricLightScatteringPixelShader: {
  53381. name: string;
  53382. shader: string;
  53383. };
  53384. }
  53385. declare module BABYLON {
  53386. /** @hidden */
  53387. export var volumetricLightScatteringPassPixelShader: {
  53388. name: string;
  53389. shader: string;
  53390. };
  53391. }
  53392. declare module BABYLON {
  53393. /**
  53394. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  53395. */
  53396. export class VolumetricLightScatteringPostProcess extends PostProcess {
  53397. private _volumetricLightScatteringPass;
  53398. private _volumetricLightScatteringRTT;
  53399. private _viewPort;
  53400. private _screenCoordinates;
  53401. private _cachedDefines;
  53402. /**
  53403. * If not undefined, the mesh position is computed from the attached node position
  53404. */
  53405. attachedNode: {
  53406. position: Vector3;
  53407. };
  53408. /**
  53409. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  53410. */
  53411. customMeshPosition: Vector3;
  53412. /**
  53413. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  53414. */
  53415. useCustomMeshPosition: boolean;
  53416. /**
  53417. * If the post-process should inverse the light scattering direction
  53418. */
  53419. invert: boolean;
  53420. /**
  53421. * The internal mesh used by the post-process
  53422. */
  53423. mesh: Mesh;
  53424. /**
  53425. * @hidden
  53426. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  53427. */
  53428. useDiffuseColor: boolean;
  53429. /**
  53430. * Array containing the excluded meshes not rendered in the internal pass
  53431. */
  53432. excludedMeshes: AbstractMesh[];
  53433. /**
  53434. * Controls the overall intensity of the post-process
  53435. */
  53436. exposure: number;
  53437. /**
  53438. * Dissipates each sample's contribution in range [0, 1]
  53439. */
  53440. decay: number;
  53441. /**
  53442. * Controls the overall intensity of each sample
  53443. */
  53444. weight: number;
  53445. /**
  53446. * Controls the density of each sample
  53447. */
  53448. density: number;
  53449. /**
  53450. * @constructor
  53451. * @param name The post-process name
  53452. * @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)
  53453. * @param camera The camera that the post-process will be attached to
  53454. * @param mesh The mesh used to create the light scattering
  53455. * @param samples The post-process quality, default 100
  53456. * @param samplingModeThe post-process filtering mode
  53457. * @param engine The babylon engine
  53458. * @param reusable If the post-process is reusable
  53459. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  53460. */
  53461. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  53462. /**
  53463. * Returns the string "VolumetricLightScatteringPostProcess"
  53464. * @returns "VolumetricLightScatteringPostProcess"
  53465. */
  53466. getClassName(): string;
  53467. private _isReady;
  53468. /**
  53469. * Sets the new light position for light scattering effect
  53470. * @param position The new custom light position
  53471. */
  53472. setCustomMeshPosition(position: Vector3): void;
  53473. /**
  53474. * Returns the light position for light scattering effect
  53475. * @return Vector3 The custom light position
  53476. */
  53477. getCustomMeshPosition(): Vector3;
  53478. /**
  53479. * Disposes the internal assets and detaches the post-process from the camera
  53480. */
  53481. dispose(camera: Camera): void;
  53482. /**
  53483. * Returns the render target texture used by the post-process
  53484. * @return the render target texture used by the post-process
  53485. */
  53486. getPass(): RenderTargetTexture;
  53487. private _meshExcluded;
  53488. private _createPass;
  53489. private _updateMeshScreenCoordinates;
  53490. /**
  53491. * Creates a default mesh for the Volumeric Light Scattering post-process
  53492. * @param name The mesh name
  53493. * @param scene The scene where to create the mesh
  53494. * @return the default mesh
  53495. */
  53496. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  53497. }
  53498. }
  53499. declare module BABYLON {
  53500. interface Scene {
  53501. /** @hidden (Backing field) */ boundingBoxRenderer: BoundingBoxRenderer;
  53502. /** @hidden (Backing field) */ forceShowBoundingBoxes: boolean;
  53503. /**
  53504. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  53505. */
  53506. forceShowBoundingBoxes: boolean;
  53507. /**
  53508. * Gets the bounding box renderer associated with the scene
  53509. * @returns a BoundingBoxRenderer
  53510. */
  53511. getBoundingBoxRenderer(): BoundingBoxRenderer;
  53512. }
  53513. interface AbstractMesh {
  53514. /** @hidden (Backing field) */ showBoundingBox: boolean;
  53515. /**
  53516. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  53517. */
  53518. showBoundingBox: boolean;
  53519. }
  53520. /**
  53521. * Component responsible of rendering the bounding box of the meshes in a scene.
  53522. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  53523. */
  53524. export class BoundingBoxRenderer implements ISceneComponent {
  53525. /**
  53526. * The component name helpfull to identify the component in the list of scene components.
  53527. */
  53528. readonly name: string;
  53529. /**
  53530. * The scene the component belongs to.
  53531. */
  53532. scene: Scene;
  53533. /**
  53534. * Color of the bounding box lines placed in front of an object
  53535. */
  53536. frontColor: Color3;
  53537. /**
  53538. * Color of the bounding box lines placed behind an object
  53539. */
  53540. backColor: Color3;
  53541. /**
  53542. * Defines if the renderer should show the back lines or not
  53543. */
  53544. showBackLines: boolean;
  53545. /**
  53546. * @hidden
  53547. */
  53548. renderList: SmartArray<BoundingBox>;
  53549. private _colorShader;
  53550. private _vertexBuffers;
  53551. private _indexBuffer;
  53552. /**
  53553. * Instantiates a new bounding box renderer in a scene.
  53554. * @param scene the scene the renderer renders in
  53555. */
  53556. constructor(scene: Scene);
  53557. /**
  53558. * Registers the component in a given scene
  53559. */
  53560. register(): void;
  53561. private _evaluateSubMesh;
  53562. private _activeMesh;
  53563. private _prepareRessources;
  53564. private _createIndexBuffer;
  53565. /**
  53566. * Rebuilds the elements related to this component in case of
  53567. * context lost for instance.
  53568. */
  53569. rebuild(): void;
  53570. /**
  53571. * @hidden
  53572. */
  53573. reset(): void;
  53574. /**
  53575. * Render the bounding boxes of a specific rendering group
  53576. * @param renderingGroupId defines the rendering group to render
  53577. */
  53578. render(renderingGroupId: number): void;
  53579. /**
  53580. * In case of occlusion queries, we can render the occlusion bounding box through this method
  53581. * @param mesh Define the mesh to render the occlusion bounding box for
  53582. */
  53583. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  53584. /**
  53585. * Dispose and release the resources attached to this renderer.
  53586. */
  53587. dispose(): void;
  53588. }
  53589. }
  53590. declare module BABYLON {
  53591. /** @hidden */
  53592. export var depthPixelShader: {
  53593. name: string;
  53594. shader: string;
  53595. };
  53596. }
  53597. declare module BABYLON {
  53598. /**
  53599. * This represents a depth renderer in Babylon.
  53600. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  53601. */
  53602. export class DepthRenderer {
  53603. private _scene;
  53604. private _depthMap;
  53605. private _effect;
  53606. private _cachedDefines;
  53607. private _camera;
  53608. /**
  53609. * Specifiess that the depth renderer will only be used within
  53610. * the camera it is created for.
  53611. * This can help forcing its rendering during the camera processing.
  53612. */
  53613. useOnlyInActiveCamera: boolean;
  53614. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  53615. /**
  53616. * Instantiates a depth renderer
  53617. * @param scene The scene the renderer belongs to
  53618. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  53619. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  53620. */
  53621. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  53622. /**
  53623. * Creates the depth rendering effect and checks if the effect is ready.
  53624. * @param subMesh The submesh to be used to render the depth map of
  53625. * @param useInstances If multiple world instances should be used
  53626. * @returns if the depth renderer is ready to render the depth map
  53627. */
  53628. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53629. /**
  53630. * Gets the texture which the depth map will be written to.
  53631. * @returns The depth map texture
  53632. */
  53633. getDepthMap(): RenderTargetTexture;
  53634. /**
  53635. * Disposes of the depth renderer.
  53636. */
  53637. dispose(): void;
  53638. }
  53639. }
  53640. declare module BABYLON {
  53641. interface Scene {
  53642. /** @hidden (Backing field) */ depthRenderer: {
  53643. [id: string]: DepthRenderer;
  53644. };
  53645. /**
  53646. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  53647. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  53648. * @returns the created depth renderer
  53649. */
  53650. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  53651. /**
  53652. * Disables a depth renderer for a given camera
  53653. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  53654. */
  53655. disableDepthRenderer(camera?: Nullable<Camera>): void;
  53656. }
  53657. /**
  53658. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  53659. * in several rendering techniques.
  53660. */
  53661. export class DepthRendererSceneComponent implements ISceneComponent {
  53662. /**
  53663. * The component name helpfull to identify the component in the list of scene components.
  53664. */
  53665. readonly name: string;
  53666. /**
  53667. * The scene the component belongs to.
  53668. */
  53669. scene: Scene;
  53670. /**
  53671. * Creates a new instance of the component for the given scene
  53672. * @param scene Defines the scene to register the component in
  53673. */
  53674. constructor(scene: Scene);
  53675. /**
  53676. * Registers the component in a given scene
  53677. */
  53678. register(): void;
  53679. /**
  53680. * Rebuilds the elements related to this component in case of
  53681. * context lost for instance.
  53682. */
  53683. rebuild(): void;
  53684. /**
  53685. * Disposes the component and the associated ressources
  53686. */
  53687. dispose(): void;
  53688. private _gatherRenderTargets;
  53689. private _gatherActiveCameraRenderTargets;
  53690. }
  53691. }
  53692. declare module BABYLON {
  53693. /** @hidden */
  53694. export var outlinePixelShader: {
  53695. name: string;
  53696. shader: string;
  53697. };
  53698. }
  53699. declare module BABYLON {
  53700. /** @hidden */
  53701. export var outlineVertexShader: {
  53702. name: string;
  53703. shader: string;
  53704. };
  53705. }
  53706. declare module BABYLON {
  53707. interface Scene {
  53708. /** @hidden */ outlineRenderer: OutlineRenderer;
  53709. /**
  53710. * Gets the outline renderer associated with the scene
  53711. * @returns a OutlineRenderer
  53712. */
  53713. getOutlineRenderer(): OutlineRenderer;
  53714. }
  53715. interface AbstractMesh {
  53716. /** @hidden (Backing field) */ renderOutline: boolean;
  53717. /**
  53718. * Gets or sets a boolean indicating if the outline must be rendered as well
  53719. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  53720. */
  53721. renderOutline: boolean;
  53722. /** @hidden (Backing field) */ renderOverlay: boolean;
  53723. /**
  53724. * Gets or sets a boolean indicating if the overlay must be rendered as well
  53725. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  53726. */
  53727. renderOverlay: boolean;
  53728. }
  53729. /**
  53730. * This class is responsible to draw bothe outline/overlay of meshes.
  53731. * It should not be used directly but through the available method on mesh.
  53732. */
  53733. export class OutlineRenderer implements ISceneComponent {
  53734. /**
  53735. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  53736. */
  53737. private static _StencilReference;
  53738. /**
  53739. * The name of the component. Each component must have a unique name.
  53740. */
  53741. name: string;
  53742. /**
  53743. * The scene the component belongs to.
  53744. */
  53745. scene: Scene;
  53746. /**
  53747. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  53748. */
  53749. zOffset: number;
  53750. private _engine;
  53751. private _effect;
  53752. private _cachedDefines;
  53753. private _savedDepthWrite;
  53754. /**
  53755. * Instantiates a new outline renderer. (There could be only one per scene).
  53756. * @param scene Defines the scene it belongs to
  53757. */
  53758. constructor(scene: Scene);
  53759. /**
  53760. * Register the component to one instance of a scene.
  53761. */
  53762. register(): void;
  53763. /**
  53764. * Rebuilds the elements related to this component in case of
  53765. * context lost for instance.
  53766. */
  53767. rebuild(): void;
  53768. /**
  53769. * Disposes the component and the associated ressources.
  53770. */
  53771. dispose(): void;
  53772. /**
  53773. * Renders the outline in the canvas.
  53774. * @param subMesh Defines the sumesh to render
  53775. * @param batch Defines the batch of meshes in case of instances
  53776. * @param useOverlay Defines if the rendering is for the overlay or the outline
  53777. */
  53778. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  53779. /**
  53780. * Returns whether or not the outline renderer is ready for a given submesh.
  53781. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  53782. * @param subMesh Defines the submesh to check readyness for
  53783. * @param useInstances Defines wheter wee are trying to render instances or not
  53784. * @returns true if ready otherwise false
  53785. */
  53786. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53787. private _beforeRenderingMesh;
  53788. private _afterRenderingMesh;
  53789. }
  53790. }
  53791. declare module BABYLON {
  53792. /**
  53793. * Defines the list of states available for a task inside a AssetsManager
  53794. */
  53795. export enum AssetTaskState {
  53796. /**
  53797. * Initialization
  53798. */
  53799. INIT = 0,
  53800. /**
  53801. * Running
  53802. */
  53803. RUNNING = 1,
  53804. /**
  53805. * Done
  53806. */
  53807. DONE = 2,
  53808. /**
  53809. * Error
  53810. */
  53811. ERROR = 3
  53812. }
  53813. /**
  53814. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  53815. */
  53816. export abstract class AbstractAssetTask {
  53817. /**
  53818. * Task name
  53819. */ name: string;
  53820. /**
  53821. * Callback called when the task is successful
  53822. */
  53823. onSuccess: (task: any) => void;
  53824. /**
  53825. * Callback called when the task is not successful
  53826. */
  53827. onError: (task: any, message?: string, exception?: any) => void;
  53828. /**
  53829. * Creates a new AssetsManager
  53830. * @param name defines the name of the task
  53831. */
  53832. constructor(
  53833. /**
  53834. * Task name
  53835. */ name: string);
  53836. private _isCompleted;
  53837. private _taskState;
  53838. private _errorObject;
  53839. /**
  53840. * Get if the task is completed
  53841. */
  53842. readonly isCompleted: boolean;
  53843. /**
  53844. * Gets the current state of the task
  53845. */
  53846. readonly taskState: AssetTaskState;
  53847. /**
  53848. * Gets the current error object (if task is in error)
  53849. */
  53850. readonly errorObject: {
  53851. message?: string;
  53852. exception?: any;
  53853. };
  53854. /**
  53855. * Internal only
  53856. * @hidden
  53857. */ setErrorObject(message?: string, exception?: any): void;
  53858. /**
  53859. * Execute the current task
  53860. * @param scene defines the scene where you want your assets to be loaded
  53861. * @param onSuccess is a callback called when the task is successfully executed
  53862. * @param onError is a callback called if an error occurs
  53863. */
  53864. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53865. /**
  53866. * Execute the current task
  53867. * @param scene defines the scene where you want your assets to be loaded
  53868. * @param onSuccess is a callback called when the task is successfully executed
  53869. * @param onError is a callback called if an error occurs
  53870. */
  53871. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53872. /**
  53873. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  53874. * This can be used with failed tasks that have the reason for failure fixed.
  53875. */
  53876. reset(): void;
  53877. private onErrorCallback;
  53878. private onDoneCallback;
  53879. }
  53880. /**
  53881. * Define the interface used by progress events raised during assets loading
  53882. */
  53883. export interface IAssetsProgressEvent {
  53884. /**
  53885. * Defines the number of remaining tasks to process
  53886. */
  53887. remainingCount: number;
  53888. /**
  53889. * Defines the total number of tasks
  53890. */
  53891. totalCount: number;
  53892. /**
  53893. * Defines the task that was just processed
  53894. */
  53895. task: AbstractAssetTask;
  53896. }
  53897. /**
  53898. * Class used to share progress information about assets loading
  53899. */
  53900. export class AssetsProgressEvent implements IAssetsProgressEvent {
  53901. /**
  53902. * Defines the number of remaining tasks to process
  53903. */
  53904. remainingCount: number;
  53905. /**
  53906. * Defines the total number of tasks
  53907. */
  53908. totalCount: number;
  53909. /**
  53910. * Defines the task that was just processed
  53911. */
  53912. task: AbstractAssetTask;
  53913. /**
  53914. * Creates a AssetsProgressEvent
  53915. * @param remainingCount defines the number of remaining tasks to process
  53916. * @param totalCount defines the total number of tasks
  53917. * @param task defines the task that was just processed
  53918. */
  53919. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  53920. }
  53921. /**
  53922. * Define a task used by AssetsManager to load meshes
  53923. */
  53924. export class MeshAssetTask extends AbstractAssetTask {
  53925. /**
  53926. * Defines the name of the task
  53927. */
  53928. name: string;
  53929. /**
  53930. * Defines the list of mesh's names you want to load
  53931. */
  53932. meshesNames: any;
  53933. /**
  53934. * Defines the root url to use as a base to load your meshes and associated resources
  53935. */
  53936. rootUrl: string;
  53937. /**
  53938. * Defines the filename of the scene to load from
  53939. */
  53940. sceneFilename: string;
  53941. /**
  53942. * Gets the list of loaded meshes
  53943. */
  53944. loadedMeshes: Array<AbstractMesh>;
  53945. /**
  53946. * Gets the list of loaded particle systems
  53947. */
  53948. loadedParticleSystems: Array<IParticleSystem>;
  53949. /**
  53950. * Gets the list of loaded skeletons
  53951. */
  53952. loadedSkeletons: Array<Skeleton>;
  53953. /**
  53954. * Gets the list of loaded animation groups
  53955. */
  53956. loadedAnimationGroups: Array<AnimationGroup>;
  53957. /**
  53958. * Callback called when the task is successful
  53959. */
  53960. onSuccess: (task: MeshAssetTask) => void;
  53961. /**
  53962. * Callback called when the task is successful
  53963. */
  53964. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  53965. /**
  53966. * Creates a new MeshAssetTask
  53967. * @param name defines the name of the task
  53968. * @param meshesNames defines the list of mesh's names you want to load
  53969. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  53970. * @param sceneFilename defines the filename of the scene to load from
  53971. */
  53972. constructor(
  53973. /**
  53974. * Defines the name of the task
  53975. */
  53976. name: string,
  53977. /**
  53978. * Defines the list of mesh's names you want to load
  53979. */
  53980. meshesNames: any,
  53981. /**
  53982. * Defines the root url to use as a base to load your meshes and associated resources
  53983. */
  53984. rootUrl: string,
  53985. /**
  53986. * Defines the filename of the scene to load from
  53987. */
  53988. sceneFilename: string);
  53989. /**
  53990. * Execute the current task
  53991. * @param scene defines the scene where you want your assets to be loaded
  53992. * @param onSuccess is a callback called when the task is successfully executed
  53993. * @param onError is a callback called if an error occurs
  53994. */
  53995. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53996. }
  53997. /**
  53998. * Define a task used by AssetsManager to load text content
  53999. */
  54000. export class TextFileAssetTask extends AbstractAssetTask {
  54001. /**
  54002. * Defines the name of the task
  54003. */
  54004. name: string;
  54005. /**
  54006. * Defines the location of the file to load
  54007. */
  54008. url: string;
  54009. /**
  54010. * Gets the loaded text string
  54011. */
  54012. text: string;
  54013. /**
  54014. * Callback called when the task is successful
  54015. */
  54016. onSuccess: (task: TextFileAssetTask) => void;
  54017. /**
  54018. * Callback called when the task is successful
  54019. */
  54020. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  54021. /**
  54022. * Creates a new TextFileAssetTask object
  54023. * @param name defines the name of the task
  54024. * @param url defines the location of the file to load
  54025. */
  54026. constructor(
  54027. /**
  54028. * Defines the name of the task
  54029. */
  54030. name: string,
  54031. /**
  54032. * Defines the location of the file to load
  54033. */
  54034. url: string);
  54035. /**
  54036. * Execute the current task
  54037. * @param scene defines the scene where you want your assets to be loaded
  54038. * @param onSuccess is a callback called when the task is successfully executed
  54039. * @param onError is a callback called if an error occurs
  54040. */
  54041. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54042. }
  54043. /**
  54044. * Define a task used by AssetsManager to load binary data
  54045. */
  54046. export class BinaryFileAssetTask extends AbstractAssetTask {
  54047. /**
  54048. * Defines the name of the task
  54049. */
  54050. name: string;
  54051. /**
  54052. * Defines the location of the file to load
  54053. */
  54054. url: string;
  54055. /**
  54056. * Gets the lodaded data (as an array buffer)
  54057. */
  54058. data: ArrayBuffer;
  54059. /**
  54060. * Callback called when the task is successful
  54061. */
  54062. onSuccess: (task: BinaryFileAssetTask) => void;
  54063. /**
  54064. * Callback called when the task is successful
  54065. */
  54066. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  54067. /**
  54068. * Creates a new BinaryFileAssetTask object
  54069. * @param name defines the name of the new task
  54070. * @param url defines the location of the file to load
  54071. */
  54072. constructor(
  54073. /**
  54074. * Defines the name of the task
  54075. */
  54076. name: string,
  54077. /**
  54078. * Defines the location of the file to load
  54079. */
  54080. url: string);
  54081. /**
  54082. * Execute the current task
  54083. * @param scene defines the scene where you want your assets to be loaded
  54084. * @param onSuccess is a callback called when the task is successfully executed
  54085. * @param onError is a callback called if an error occurs
  54086. */
  54087. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54088. }
  54089. /**
  54090. * Define a task used by AssetsManager to load images
  54091. */
  54092. export class ImageAssetTask extends AbstractAssetTask {
  54093. /**
  54094. * Defines the name of the task
  54095. */
  54096. name: string;
  54097. /**
  54098. * Defines the location of the image to load
  54099. */
  54100. url: string;
  54101. /**
  54102. * Gets the loaded images
  54103. */
  54104. image: HTMLImageElement;
  54105. /**
  54106. * Callback called when the task is successful
  54107. */
  54108. onSuccess: (task: ImageAssetTask) => void;
  54109. /**
  54110. * Callback called when the task is successful
  54111. */
  54112. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  54113. /**
  54114. * Creates a new ImageAssetTask
  54115. * @param name defines the name of the task
  54116. * @param url defines the location of the image to load
  54117. */
  54118. constructor(
  54119. /**
  54120. * Defines the name of the task
  54121. */
  54122. name: string,
  54123. /**
  54124. * Defines the location of the image to load
  54125. */
  54126. url: string);
  54127. /**
  54128. * Execute the current task
  54129. * @param scene defines the scene where you want your assets to be loaded
  54130. * @param onSuccess is a callback called when the task is successfully executed
  54131. * @param onError is a callback called if an error occurs
  54132. */
  54133. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54134. }
  54135. /**
  54136. * Defines the interface used by texture loading tasks
  54137. */
  54138. export interface ITextureAssetTask<TEX extends BaseTexture> {
  54139. /**
  54140. * Gets the loaded texture
  54141. */
  54142. texture: TEX;
  54143. }
  54144. /**
  54145. * Define a task used by AssetsManager to load 2D textures
  54146. */
  54147. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  54148. /**
  54149. * Defines the name of the task
  54150. */
  54151. name: string;
  54152. /**
  54153. * Defines the location of the file to load
  54154. */
  54155. url: string;
  54156. /**
  54157. * Defines if mipmap should not be generated (default is false)
  54158. */
  54159. noMipmap?: boolean | undefined;
  54160. /**
  54161. * Defines if texture must be inverted on Y axis (default is false)
  54162. */
  54163. invertY?: boolean | undefined;
  54164. /**
  54165. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54166. */
  54167. samplingMode: number;
  54168. /**
  54169. * Gets the loaded texture
  54170. */
  54171. texture: Texture;
  54172. /**
  54173. * Callback called when the task is successful
  54174. */
  54175. onSuccess: (task: TextureAssetTask) => void;
  54176. /**
  54177. * Callback called when the task is successful
  54178. */
  54179. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  54180. /**
  54181. * Creates a new TextureAssetTask object
  54182. * @param name defines the name of the task
  54183. * @param url defines the location of the file to load
  54184. * @param noMipmap defines if mipmap should not be generated (default is false)
  54185. * @param invertY defines if texture must be inverted on Y axis (default is false)
  54186. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54187. */
  54188. constructor(
  54189. /**
  54190. * Defines the name of the task
  54191. */
  54192. name: string,
  54193. /**
  54194. * Defines the location of the file to load
  54195. */
  54196. url: string,
  54197. /**
  54198. * Defines if mipmap should not be generated (default is false)
  54199. */
  54200. noMipmap?: boolean | undefined,
  54201. /**
  54202. * Defines if texture must be inverted on Y axis (default is false)
  54203. */
  54204. invertY?: boolean | undefined,
  54205. /**
  54206. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54207. */
  54208. samplingMode?: number);
  54209. /**
  54210. * Execute the current task
  54211. * @param scene defines the scene where you want your assets to be loaded
  54212. * @param onSuccess is a callback called when the task is successfully executed
  54213. * @param onError is a callback called if an error occurs
  54214. */
  54215. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54216. }
  54217. /**
  54218. * Define a task used by AssetsManager to load cube textures
  54219. */
  54220. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  54221. /**
  54222. * Defines the name of the task
  54223. */
  54224. name: string;
  54225. /**
  54226. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54227. */
  54228. url: string;
  54229. /**
  54230. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54231. */
  54232. extensions?: string[] | undefined;
  54233. /**
  54234. * Defines if mipmaps should not be generated (default is false)
  54235. */
  54236. noMipmap?: boolean | undefined;
  54237. /**
  54238. * Defines the explicit list of files (undefined by default)
  54239. */
  54240. files?: string[] | undefined;
  54241. /**
  54242. * Gets the loaded texture
  54243. */
  54244. texture: CubeTexture;
  54245. /**
  54246. * Callback called when the task is successful
  54247. */
  54248. onSuccess: (task: CubeTextureAssetTask) => void;
  54249. /**
  54250. * Callback called when the task is successful
  54251. */
  54252. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  54253. /**
  54254. * Creates a new CubeTextureAssetTask
  54255. * @param name defines the name of the task
  54256. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54257. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54258. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54259. * @param files defines the explicit list of files (undefined by default)
  54260. */
  54261. constructor(
  54262. /**
  54263. * Defines the name of the task
  54264. */
  54265. name: string,
  54266. /**
  54267. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54268. */
  54269. url: string,
  54270. /**
  54271. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54272. */
  54273. extensions?: string[] | undefined,
  54274. /**
  54275. * Defines if mipmaps should not be generated (default is false)
  54276. */
  54277. noMipmap?: boolean | undefined,
  54278. /**
  54279. * Defines the explicit list of files (undefined by default)
  54280. */
  54281. files?: string[] | undefined);
  54282. /**
  54283. * Execute the current task
  54284. * @param scene defines the scene where you want your assets to be loaded
  54285. * @param onSuccess is a callback called when the task is successfully executed
  54286. * @param onError is a callback called if an error occurs
  54287. */
  54288. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54289. }
  54290. /**
  54291. * Define a task used by AssetsManager to load HDR cube textures
  54292. */
  54293. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  54294. /**
  54295. * Defines the name of the task
  54296. */
  54297. name: string;
  54298. /**
  54299. * Defines the location of the file to load
  54300. */
  54301. url: string;
  54302. /**
  54303. * Defines the desired size (the more it increases the longer the generation will be)
  54304. */
  54305. size: number;
  54306. /**
  54307. * Defines if mipmaps should not be generated (default is false)
  54308. */
  54309. noMipmap: boolean;
  54310. /**
  54311. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54312. */
  54313. generateHarmonics: boolean;
  54314. /**
  54315. * 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)
  54316. */
  54317. gammaSpace: boolean;
  54318. /**
  54319. * Internal Use Only
  54320. */
  54321. reserved: boolean;
  54322. /**
  54323. * Gets the loaded texture
  54324. */
  54325. texture: HDRCubeTexture;
  54326. /**
  54327. * Callback called when the task is successful
  54328. */
  54329. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  54330. /**
  54331. * Callback called when the task is successful
  54332. */
  54333. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  54334. /**
  54335. * Creates a new HDRCubeTextureAssetTask object
  54336. * @param name defines the name of the task
  54337. * @param url defines the location of the file to load
  54338. * @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.
  54339. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54340. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54341. * @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)
  54342. * @param reserved Internal use only
  54343. */
  54344. constructor(
  54345. /**
  54346. * Defines the name of the task
  54347. */
  54348. name: string,
  54349. /**
  54350. * Defines the location of the file to load
  54351. */
  54352. url: string,
  54353. /**
  54354. * Defines the desired size (the more it increases the longer the generation will be)
  54355. */
  54356. size: number,
  54357. /**
  54358. * Defines if mipmaps should not be generated (default is false)
  54359. */
  54360. noMipmap?: boolean,
  54361. /**
  54362. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54363. */
  54364. generateHarmonics?: boolean,
  54365. /**
  54366. * 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)
  54367. */
  54368. gammaSpace?: boolean,
  54369. /**
  54370. * Internal Use Only
  54371. */
  54372. reserved?: boolean);
  54373. /**
  54374. * Execute the current task
  54375. * @param scene defines the scene where you want your assets to be loaded
  54376. * @param onSuccess is a callback called when the task is successfully executed
  54377. * @param onError is a callback called if an error occurs
  54378. */
  54379. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54380. }
  54381. /**
  54382. * Define a task used by AssetsManager to load Equirectangular cube textures
  54383. */
  54384. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  54385. /**
  54386. * Defines the name of the task
  54387. */
  54388. name: string;
  54389. /**
  54390. * Defines the location of the file to load
  54391. */
  54392. url: string;
  54393. /**
  54394. * Defines the desired size (the more it increases the longer the generation will be)
  54395. */
  54396. size: number;
  54397. /**
  54398. * Defines if mipmaps should not be generated (default is false)
  54399. */
  54400. noMipmap: boolean;
  54401. /**
  54402. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  54403. * but the standard material would require them in Gamma space) (default is true)
  54404. */
  54405. gammaSpace: boolean;
  54406. /**
  54407. * Gets the loaded texture
  54408. */
  54409. texture: EquiRectangularCubeTexture;
  54410. /**
  54411. * Callback called when the task is successful
  54412. */
  54413. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  54414. /**
  54415. * Callback called when the task is successful
  54416. */
  54417. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  54418. /**
  54419. * Creates a new EquiRectangularCubeTextureAssetTask object
  54420. * @param name defines the name of the task
  54421. * @param url defines the location of the file to load
  54422. * @param size defines the desired size (the more it increases the longer the generation will be)
  54423. * If the size is omitted this implies you are using a preprocessed cubemap.
  54424. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54425. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  54426. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  54427. * (default is true)
  54428. */
  54429. constructor(
  54430. /**
  54431. * Defines the name of the task
  54432. */
  54433. name: string,
  54434. /**
  54435. * Defines the location of the file to load
  54436. */
  54437. url: string,
  54438. /**
  54439. * Defines the desired size (the more it increases the longer the generation will be)
  54440. */
  54441. size: number,
  54442. /**
  54443. * Defines if mipmaps should not be generated (default is false)
  54444. */
  54445. noMipmap?: boolean,
  54446. /**
  54447. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  54448. * but the standard material would require them in Gamma space) (default is true)
  54449. */
  54450. gammaSpace?: boolean);
  54451. /**
  54452. * Execute the current task
  54453. * @param scene defines the scene where you want your assets to be loaded
  54454. * @param onSuccess is a callback called when the task is successfully executed
  54455. * @param onError is a callback called if an error occurs
  54456. */
  54457. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54458. }
  54459. /**
  54460. * This class can be used to easily import assets into a scene
  54461. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  54462. */
  54463. export class AssetsManager {
  54464. private _scene;
  54465. private _isLoading;
  54466. protected _tasks: AbstractAssetTask[];
  54467. protected _waitingTasksCount: number;
  54468. protected _totalTasksCount: number;
  54469. /**
  54470. * Callback called when all tasks are processed
  54471. */
  54472. onFinish: (tasks: AbstractAssetTask[]) => void;
  54473. /**
  54474. * Callback called when a task is successful
  54475. */
  54476. onTaskSuccess: (task: AbstractAssetTask) => void;
  54477. /**
  54478. * Callback called when a task had an error
  54479. */
  54480. onTaskError: (task: AbstractAssetTask) => void;
  54481. /**
  54482. * Callback called when a task is done (whatever the result is)
  54483. */
  54484. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  54485. /**
  54486. * Observable called when all tasks are processed
  54487. */
  54488. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  54489. /**
  54490. * Observable called when a task had an error
  54491. */
  54492. onTaskErrorObservable: Observable<AbstractAssetTask>;
  54493. /**
  54494. * Observable called when all tasks were executed
  54495. */
  54496. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  54497. /**
  54498. * Observable called when a task is done (whatever the result is)
  54499. */
  54500. onProgressObservable: Observable<IAssetsProgressEvent>;
  54501. /**
  54502. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  54503. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  54504. */
  54505. useDefaultLoadingScreen: boolean;
  54506. /**
  54507. * Creates a new AssetsManager
  54508. * @param scene defines the scene to work on
  54509. */
  54510. constructor(scene: Scene);
  54511. /**
  54512. * Add a MeshAssetTask to the list of active tasks
  54513. * @param taskName defines the name of the new task
  54514. * @param meshesNames defines the name of meshes to load
  54515. * @param rootUrl defines the root url to use to locate files
  54516. * @param sceneFilename defines the filename of the scene file
  54517. * @returns a new MeshAssetTask object
  54518. */
  54519. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  54520. /**
  54521. * Add a TextFileAssetTask to the list of active tasks
  54522. * @param taskName defines the name of the new task
  54523. * @param url defines the url of the file to load
  54524. * @returns a new TextFileAssetTask object
  54525. */
  54526. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  54527. /**
  54528. * Add a BinaryFileAssetTask to the list of active tasks
  54529. * @param taskName defines the name of the new task
  54530. * @param url defines the url of the file to load
  54531. * @returns a new BinaryFileAssetTask object
  54532. */
  54533. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  54534. /**
  54535. * Add a ImageAssetTask to the list of active tasks
  54536. * @param taskName defines the name of the new task
  54537. * @param url defines the url of the file to load
  54538. * @returns a new ImageAssetTask object
  54539. */
  54540. addImageTask(taskName: string, url: string): ImageAssetTask;
  54541. /**
  54542. * Add a TextureAssetTask to the list of active tasks
  54543. * @param taskName defines the name of the new task
  54544. * @param url defines the url of the file to load
  54545. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54546. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  54547. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54548. * @returns a new TextureAssetTask object
  54549. */
  54550. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  54551. /**
  54552. * Add a CubeTextureAssetTask to the list of active tasks
  54553. * @param taskName defines the name of the new task
  54554. * @param url defines the url of the file to load
  54555. * @param extensions defines the extension to use to load the cube map (can be null)
  54556. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54557. * @param files defines the list of files to load (can be null)
  54558. * @returns a new CubeTextureAssetTask object
  54559. */
  54560. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  54561. /**
  54562. *
  54563. * Add a HDRCubeTextureAssetTask to the list of active tasks
  54564. * @param taskName defines the name of the new task
  54565. * @param url defines the url of the file to load
  54566. * @param size defines the size you want for the cubemap (can be null)
  54567. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54568. * @param generateHarmonics defines if you want to automatically generate (true by default)
  54569. * @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)
  54570. * @param reserved Internal use only
  54571. * @returns a new HDRCubeTextureAssetTask object
  54572. */
  54573. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  54574. /**
  54575. *
  54576. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  54577. * @param taskName defines the name of the new task
  54578. * @param url defines the url of the file to load
  54579. * @param size defines the size you want for the cubemap (can be null)
  54580. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54581. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54582. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54583. * @returns a new EquiRectangularCubeTextureAssetTask object
  54584. */
  54585. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  54586. /**
  54587. * Remove a task from the assets manager.
  54588. * @param task the task to remove
  54589. */
  54590. removeTask(task: AbstractAssetTask): void;
  54591. private _decreaseWaitingTasksCount;
  54592. private _runTask;
  54593. /**
  54594. * Reset the AssetsManager and remove all tasks
  54595. * @return the current instance of the AssetsManager
  54596. */
  54597. reset(): AssetsManager;
  54598. /**
  54599. * Start the loading process
  54600. * @return the current instance of the AssetsManager
  54601. */
  54602. load(): AssetsManager;
  54603. /**
  54604. * Start the loading process as an async operation
  54605. * @return a promise returning the list of failed tasks
  54606. */
  54607. loadAsync(): Promise<void>;
  54608. }
  54609. }
  54610. declare module BABYLON {
  54611. /**
  54612. * Wrapper class for promise with external resolve and reject.
  54613. */
  54614. export class Deferred<T> {
  54615. /**
  54616. * The promise associated with this deferred object.
  54617. */
  54618. readonly promise: Promise<T>;
  54619. private _resolve;
  54620. private _reject;
  54621. /**
  54622. * The resolve method of the promise associated with this deferred object.
  54623. */
  54624. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  54625. /**
  54626. * The reject method of the promise associated with this deferred object.
  54627. */
  54628. readonly reject: (reason?: any) => void;
  54629. /**
  54630. * Constructor for this deferred object.
  54631. */
  54632. constructor();
  54633. }
  54634. }
  54635. declare module BABYLON {
  54636. /**
  54637. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  54638. */
  54639. export class MeshExploder {
  54640. private _centerMesh;
  54641. private _meshes;
  54642. private _meshesOrigins;
  54643. private _toCenterVectors;
  54644. private _scaledDirection;
  54645. private _newPosition;
  54646. private _centerPosition;
  54647. /**
  54648. * Explodes meshes from a center mesh.
  54649. * @param meshes The meshes to explode.
  54650. * @param centerMesh The mesh to be center of explosion.
  54651. */
  54652. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  54653. private _setCenterMesh;
  54654. /**
  54655. * Get class name
  54656. * @returns "MeshExploder"
  54657. */
  54658. getClassName(): string;
  54659. /**
  54660. * "Exploded meshes"
  54661. * @returns Array of meshes with the centerMesh at index 0.
  54662. */
  54663. getMeshes(): Array<Mesh>;
  54664. /**
  54665. * Explodes meshes giving a specific direction
  54666. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  54667. */
  54668. explode(direction?: number): void;
  54669. }
  54670. }
  54671. declare module BABYLON {
  54672. /**
  54673. * Class used to help managing file picking and drag'n'drop
  54674. */
  54675. export class FilesInput {
  54676. /**
  54677. * List of files ready to be loaded
  54678. */
  54679. static readonly FilesToLoad: {
  54680. [key: string]: File;
  54681. };
  54682. /**
  54683. * Callback called when a file is processed
  54684. */
  54685. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  54686. private _engine;
  54687. private _currentScene;
  54688. private _sceneLoadedCallback;
  54689. private _progressCallback;
  54690. private _additionalRenderLoopLogicCallback;
  54691. private _textureLoadingCallback;
  54692. private _startingProcessingFilesCallback;
  54693. private _onReloadCallback;
  54694. private _errorCallback;
  54695. private _elementToMonitor;
  54696. private _sceneFileToLoad;
  54697. private _filesToLoad;
  54698. /**
  54699. * Creates a new FilesInput
  54700. * @param engine defines the rendering engine
  54701. * @param scene defines the hosting scene
  54702. * @param sceneLoadedCallback callback called when scene is loaded
  54703. * @param progressCallback callback called to track progress
  54704. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  54705. * @param textureLoadingCallback callback called when a texture is loading
  54706. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  54707. * @param onReloadCallback callback called when a reload is requested
  54708. * @param errorCallback callback call if an error occurs
  54709. */
  54710. 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);
  54711. private _dragEnterHandler;
  54712. private _dragOverHandler;
  54713. private _dropHandler;
  54714. /**
  54715. * Calls this function to listen to drag'n'drop events on a specific DOM element
  54716. * @param elementToMonitor defines the DOM element to track
  54717. */
  54718. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  54719. /**
  54720. * Release all associated resources
  54721. */
  54722. dispose(): void;
  54723. private renderFunction;
  54724. private drag;
  54725. private drop;
  54726. private _traverseFolder;
  54727. private _processFiles;
  54728. /**
  54729. * Load files from a drop event
  54730. * @param event defines the drop event to use as source
  54731. */
  54732. loadFiles(event: any): void;
  54733. private _processReload;
  54734. /**
  54735. * Reload the current scene from the loaded files
  54736. */
  54737. reload(): void;
  54738. }
  54739. }
  54740. declare module BABYLON {
  54741. /**
  54742. * Defines the root class used to create scene optimization to use with SceneOptimizer
  54743. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54744. */
  54745. export class SceneOptimization {
  54746. /**
  54747. * Defines the priority of this optimization (0 by default which means first in the list)
  54748. */
  54749. priority: number;
  54750. /**
  54751. * Gets a string describing the action executed by the current optimization
  54752. * @returns description string
  54753. */
  54754. getDescription(): string;
  54755. /**
  54756. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54757. * @param scene defines the current scene where to apply this optimization
  54758. * @param optimizer defines the current optimizer
  54759. * @returns true if everything that can be done was applied
  54760. */
  54761. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54762. /**
  54763. * Creates the SceneOptimization object
  54764. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54765. * @param desc defines the description associated with the optimization
  54766. */
  54767. constructor(
  54768. /**
  54769. * Defines the priority of this optimization (0 by default which means first in the list)
  54770. */
  54771. priority?: number);
  54772. }
  54773. /**
  54774. * Defines an optimization used to reduce the size of render target textures
  54775. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54776. */
  54777. export class TextureOptimization extends SceneOptimization {
  54778. /**
  54779. * Defines the priority of this optimization (0 by default which means first in the list)
  54780. */
  54781. priority: number;
  54782. /**
  54783. * 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
  54784. */
  54785. maximumSize: number;
  54786. /**
  54787. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  54788. */
  54789. step: number;
  54790. /**
  54791. * Gets a string describing the action executed by the current optimization
  54792. * @returns description string
  54793. */
  54794. getDescription(): string;
  54795. /**
  54796. * Creates the TextureOptimization object
  54797. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54798. * @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
  54799. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  54800. */
  54801. constructor(
  54802. /**
  54803. * Defines the priority of this optimization (0 by default which means first in the list)
  54804. */
  54805. priority?: number,
  54806. /**
  54807. * 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
  54808. */
  54809. maximumSize?: number,
  54810. /**
  54811. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  54812. */
  54813. step?: number);
  54814. /**
  54815. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54816. * @param scene defines the current scene where to apply this optimization
  54817. * @param optimizer defines the current optimizer
  54818. * @returns true if everything that can be done was applied
  54819. */
  54820. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54821. }
  54822. /**
  54823. * Defines an optimization used to increase or decrease the rendering resolution
  54824. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54825. */
  54826. export class HardwareScalingOptimization extends SceneOptimization {
  54827. /**
  54828. * Defines the priority of this optimization (0 by default which means first in the list)
  54829. */
  54830. priority: number;
  54831. /**
  54832. * Defines the maximum scale to use (2 by default)
  54833. */
  54834. maximumScale: number;
  54835. /**
  54836. * Defines the step to use between two passes (0.5 by default)
  54837. */
  54838. step: number;
  54839. private _currentScale;
  54840. private _directionOffset;
  54841. /**
  54842. * Gets a string describing the action executed by the current optimization
  54843. * @return description string
  54844. */
  54845. getDescription(): string;
  54846. /**
  54847. * Creates the HardwareScalingOptimization object
  54848. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54849. * @param maximumScale defines the maximum scale to use (2 by default)
  54850. * @param step defines the step to use between two passes (0.5 by default)
  54851. */
  54852. constructor(
  54853. /**
  54854. * Defines the priority of this optimization (0 by default which means first in the list)
  54855. */
  54856. priority?: number,
  54857. /**
  54858. * Defines the maximum scale to use (2 by default)
  54859. */
  54860. maximumScale?: number,
  54861. /**
  54862. * Defines the step to use between two passes (0.5 by default)
  54863. */
  54864. step?: number);
  54865. /**
  54866. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54867. * @param scene defines the current scene where to apply this optimization
  54868. * @param optimizer defines the current optimizer
  54869. * @returns true if everything that can be done was applied
  54870. */
  54871. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54872. }
  54873. /**
  54874. * Defines an optimization used to remove shadows
  54875. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54876. */
  54877. export class ShadowsOptimization extends SceneOptimization {
  54878. /**
  54879. * Gets a string describing the action executed by the current optimization
  54880. * @return description string
  54881. */
  54882. getDescription(): string;
  54883. /**
  54884. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54885. * @param scene defines the current scene where to apply this optimization
  54886. * @param optimizer defines the current optimizer
  54887. * @returns true if everything that can be done was applied
  54888. */
  54889. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54890. }
  54891. /**
  54892. * Defines an optimization used to turn post-processes off
  54893. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54894. */
  54895. export class PostProcessesOptimization extends SceneOptimization {
  54896. /**
  54897. * Gets a string describing the action executed by the current optimization
  54898. * @return description string
  54899. */
  54900. getDescription(): string;
  54901. /**
  54902. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54903. * @param scene defines the current scene where to apply this optimization
  54904. * @param optimizer defines the current optimizer
  54905. * @returns true if everything that can be done was applied
  54906. */
  54907. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54908. }
  54909. /**
  54910. * Defines an optimization used to turn lens flares off
  54911. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54912. */
  54913. export class LensFlaresOptimization extends SceneOptimization {
  54914. /**
  54915. * Gets a string describing the action executed by the current optimization
  54916. * @return description string
  54917. */
  54918. getDescription(): string;
  54919. /**
  54920. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54921. * @param scene defines the current scene where to apply this optimization
  54922. * @param optimizer defines the current optimizer
  54923. * @returns true if everything that can be done was applied
  54924. */
  54925. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54926. }
  54927. /**
  54928. * Defines an optimization based on user defined callback.
  54929. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54930. */
  54931. export class CustomOptimization extends SceneOptimization {
  54932. /**
  54933. * Callback called to apply the custom optimization.
  54934. */
  54935. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  54936. /**
  54937. * Callback called to get custom description
  54938. */
  54939. onGetDescription: () => string;
  54940. /**
  54941. * Gets a string describing the action executed by the current optimization
  54942. * @returns description string
  54943. */
  54944. getDescription(): string;
  54945. /**
  54946. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54947. * @param scene defines the current scene where to apply this optimization
  54948. * @param optimizer defines the current optimizer
  54949. * @returns true if everything that can be done was applied
  54950. */
  54951. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54952. }
  54953. /**
  54954. * Defines an optimization used to turn particles off
  54955. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54956. */
  54957. export class ParticlesOptimization extends SceneOptimization {
  54958. /**
  54959. * Gets a string describing the action executed by the current optimization
  54960. * @return description string
  54961. */
  54962. getDescription(): string;
  54963. /**
  54964. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54965. * @param scene defines the current scene where to apply this optimization
  54966. * @param optimizer defines the current optimizer
  54967. * @returns true if everything that can be done was applied
  54968. */
  54969. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54970. }
  54971. /**
  54972. * Defines an optimization used to turn render targets off
  54973. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54974. */
  54975. export class RenderTargetsOptimization extends SceneOptimization {
  54976. /**
  54977. * Gets a string describing the action executed by the current optimization
  54978. * @return description string
  54979. */
  54980. getDescription(): string;
  54981. /**
  54982. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54983. * @param scene defines the current scene where to apply this optimization
  54984. * @param optimizer defines the current optimizer
  54985. * @returns true if everything that can be done was applied
  54986. */
  54987. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54988. }
  54989. /**
  54990. * Defines an optimization used to merge meshes with compatible materials
  54991. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54992. */
  54993. export class MergeMeshesOptimization extends SceneOptimization {
  54994. private static _UpdateSelectionTree;
  54995. /**
  54996. * Gets or sets a boolean which defines if optimization octree has to be updated
  54997. */
  54998. /**
  54999. * Gets or sets a boolean which defines if optimization octree has to be updated
  55000. */
  55001. static UpdateSelectionTree: boolean;
  55002. /**
  55003. * Gets a string describing the action executed by the current optimization
  55004. * @return description string
  55005. */
  55006. getDescription(): string;
  55007. private _canBeMerged;
  55008. /**
  55009. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55010. * @param scene defines the current scene where to apply this optimization
  55011. * @param optimizer defines the current optimizer
  55012. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  55013. * @returns true if everything that can be done was applied
  55014. */
  55015. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  55016. }
  55017. /**
  55018. * Defines a list of options used by SceneOptimizer
  55019. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55020. */
  55021. export class SceneOptimizerOptions {
  55022. /**
  55023. * Defines the target frame rate to reach (60 by default)
  55024. */
  55025. targetFrameRate: number;
  55026. /**
  55027. * Defines the interval between two checkes (2000ms by default)
  55028. */
  55029. trackerDuration: number;
  55030. /**
  55031. * Gets the list of optimizations to apply
  55032. */
  55033. optimizations: SceneOptimization[];
  55034. /**
  55035. * Creates a new list of options used by SceneOptimizer
  55036. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  55037. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  55038. */
  55039. constructor(
  55040. /**
  55041. * Defines the target frame rate to reach (60 by default)
  55042. */
  55043. targetFrameRate?: number,
  55044. /**
  55045. * Defines the interval between two checkes (2000ms by default)
  55046. */
  55047. trackerDuration?: number);
  55048. /**
  55049. * Add a new optimization
  55050. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  55051. * @returns the current SceneOptimizerOptions
  55052. */
  55053. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  55054. /**
  55055. * Add a new custom optimization
  55056. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  55057. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  55058. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55059. * @returns the current SceneOptimizerOptions
  55060. */
  55061. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  55062. /**
  55063. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  55064. * @param targetFrameRate defines the target frame rate (60 by default)
  55065. * @returns a SceneOptimizerOptions object
  55066. */
  55067. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55068. /**
  55069. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  55070. * @param targetFrameRate defines the target frame rate (60 by default)
  55071. * @returns a SceneOptimizerOptions object
  55072. */
  55073. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55074. /**
  55075. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  55076. * @param targetFrameRate defines the target frame rate (60 by default)
  55077. * @returns a SceneOptimizerOptions object
  55078. */
  55079. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55080. }
  55081. /**
  55082. * Class used to run optimizations in order to reach a target frame rate
  55083. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55084. */
  55085. export class SceneOptimizer implements IDisposable {
  55086. private _isRunning;
  55087. private _options;
  55088. private _scene;
  55089. private _currentPriorityLevel;
  55090. private _targetFrameRate;
  55091. private _trackerDuration;
  55092. private _currentFrameRate;
  55093. private _sceneDisposeObserver;
  55094. private _improvementMode;
  55095. /**
  55096. * Defines an observable called when the optimizer reaches the target frame rate
  55097. */
  55098. onSuccessObservable: Observable<SceneOptimizer>;
  55099. /**
  55100. * Defines an observable called when the optimizer enables an optimization
  55101. */
  55102. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  55103. /**
  55104. * Defines an observable called when the optimizer is not able to reach the target frame rate
  55105. */
  55106. onFailureObservable: Observable<SceneOptimizer>;
  55107. /**
  55108. * Gets a boolean indicating if the optimizer is in improvement mode
  55109. */
  55110. readonly isInImprovementMode: boolean;
  55111. /**
  55112. * Gets the current priority level (0 at start)
  55113. */
  55114. readonly currentPriorityLevel: number;
  55115. /**
  55116. * Gets the current frame rate checked by the SceneOptimizer
  55117. */
  55118. readonly currentFrameRate: number;
  55119. /**
  55120. * Gets or sets the current target frame rate (60 by default)
  55121. */
  55122. /**
  55123. * Gets or sets the current target frame rate (60 by default)
  55124. */
  55125. targetFrameRate: number;
  55126. /**
  55127. * Gets or sets the current interval between two checks (every 2000ms by default)
  55128. */
  55129. /**
  55130. * Gets or sets the current interval between two checks (every 2000ms by default)
  55131. */
  55132. trackerDuration: number;
  55133. /**
  55134. * Gets the list of active optimizations
  55135. */
  55136. readonly optimizations: SceneOptimization[];
  55137. /**
  55138. * Creates a new SceneOptimizer
  55139. * @param scene defines the scene to work on
  55140. * @param options defines the options to use with the SceneOptimizer
  55141. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  55142. * @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)
  55143. */
  55144. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  55145. /**
  55146. * Stops the current optimizer
  55147. */
  55148. stop(): void;
  55149. /**
  55150. * Reset the optimizer to initial step (current priority level = 0)
  55151. */
  55152. reset(): void;
  55153. /**
  55154. * Start the optimizer. By default it will try to reach a specific framerate
  55155. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  55156. */
  55157. start(): void;
  55158. private _checkCurrentState;
  55159. /**
  55160. * Release all resources
  55161. */
  55162. dispose(): void;
  55163. /**
  55164. * Helper function to create a SceneOptimizer with one single line of code
  55165. * @param scene defines the scene to work on
  55166. * @param options defines the options to use with the SceneOptimizer
  55167. * @param onSuccess defines a callback to call on success
  55168. * @param onFailure defines a callback to call on failure
  55169. * @returns the new SceneOptimizer object
  55170. */
  55171. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  55172. }
  55173. }
  55174. declare module BABYLON {
  55175. /**
  55176. * Class used to serialize a scene into a string
  55177. */
  55178. export class SceneSerializer {
  55179. /**
  55180. * Clear cache used by a previous serialization
  55181. */
  55182. static ClearCache(): void;
  55183. /**
  55184. * Serialize a scene into a JSON compatible object
  55185. * @param scene defines the scene to serialize
  55186. * @returns a JSON compatible object
  55187. */
  55188. static Serialize(scene: Scene): any;
  55189. /**
  55190. * Serialize a mesh into a JSON compatible object
  55191. * @param toSerialize defines the mesh to serialize
  55192. * @param withParents defines if parents must be serialized as well
  55193. * @param withChildren defines if children must be serialized as well
  55194. * @returns a JSON compatible object
  55195. */
  55196. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  55197. }
  55198. }
  55199. declare module BABYLON {
  55200. /**
  55201. * Class used to host texture specific utilities
  55202. */
  55203. export class TextureTools {
  55204. /**
  55205. * Uses the GPU to create a copy texture rescaled at a given size
  55206. * @param texture Texture to copy from
  55207. * @param width defines the desired width
  55208. * @param height defines the desired height
  55209. * @param useBilinearMode defines if bilinear mode has to be used
  55210. * @return the generated texture
  55211. */
  55212. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  55213. }
  55214. }
  55215. declare module BABYLON {
  55216. /**
  55217. * This represents the different options avilable for the video capture.
  55218. */
  55219. export interface VideoRecorderOptions {
  55220. /** Defines the mime type of the video */
  55221. mimeType: string;
  55222. /** Defines the video the video should be recorded at */
  55223. fps: number;
  55224. /** Defines the chunk size for the recording data */
  55225. recordChunckSize: number;
  55226. /** The audio tracks to attach to the record */
  55227. audioTracks?: MediaStreamTrack[];
  55228. }
  55229. /**
  55230. * This can helps recording videos from BabylonJS.
  55231. * This is based on the available WebRTC functionalities of the browser.
  55232. *
  55233. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  55234. */
  55235. export class VideoRecorder {
  55236. private static readonly _defaultOptions;
  55237. /**
  55238. * Returns wehther or not the VideoRecorder is available in your browser.
  55239. * @param engine Defines the Babylon Engine to check the support for
  55240. * @returns true if supported otherwise false
  55241. */
  55242. static IsSupported(engine: Engine): boolean;
  55243. private readonly _options;
  55244. private _canvas;
  55245. private _mediaRecorder;
  55246. private _recordedChunks;
  55247. private _fileName;
  55248. private _resolve;
  55249. private _reject;
  55250. /**
  55251. * True wether a recording is already in progress.
  55252. */
  55253. readonly isRecording: boolean;
  55254. /**
  55255. * Create a new VideoCapture object which can help converting what you see in Babylon to
  55256. * a video file.
  55257. * @param engine Defines the BabylonJS Engine you wish to record
  55258. * @param options Defines options that can be used to customized the capture
  55259. */
  55260. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  55261. /**
  55262. * Stops the current recording before the default capture timeout passed in the startRecording
  55263. * functions.
  55264. */
  55265. stopRecording(): void;
  55266. /**
  55267. * Starts recording the canvas for a max duration specified in parameters.
  55268. * @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.
  55269. * @param maxDuration Defines the maximum recording time in seconds.
  55270. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  55271. * @return a promise callback at the end of the recording with the video data in Blob.
  55272. */
  55273. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  55274. /**
  55275. * Releases internal resources used during the recording.
  55276. */
  55277. dispose(): void;
  55278. private _handleDataAvailable;
  55279. private _handleError;
  55280. private _handleStop;
  55281. }
  55282. }
  55283. declare module BABYLON {
  55284. /**
  55285. * Class containing a set of static utilities functions for screenshots
  55286. */
  55287. export class ScreenshotTools {
  55288. /**
  55289. * Captures a screenshot of the current rendering
  55290. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55291. * @param engine defines the rendering engine
  55292. * @param camera defines the source camera
  55293. * @param size This parameter can be set to a single number or to an object with the
  55294. * following (optional) properties: precision, width, height. If a single number is passed,
  55295. * it will be used for both width and height. If an object is passed, the screenshot size
  55296. * will be derived from the parameters. The precision property is a multiplier allowing
  55297. * rendering at a higher or lower resolution
  55298. * @param successCallback defines the callback receives a single parameter which contains the
  55299. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55300. * src parameter of an <img> to display it
  55301. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  55302. * Check your browser for supported MIME types
  55303. */
  55304. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  55305. /**
  55306. * Generates an image screenshot from the specified camera.
  55307. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55308. * @param engine The engine to use for rendering
  55309. * @param camera The camera to use for rendering
  55310. * @param size This parameter can be set to a single number or to an object with the
  55311. * following (optional) properties: precision, width, height. If a single number is passed,
  55312. * it will be used for both width and height. If an object is passed, the screenshot size
  55313. * will be derived from the parameters. The precision property is a multiplier allowing
  55314. * rendering at a higher or lower resolution
  55315. * @param successCallback The callback receives a single parameter which contains the
  55316. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55317. * src parameter of an <img> to display it
  55318. * @param mimeType The MIME type of the screenshot image (default: image/png).
  55319. * Check your browser for supported MIME types
  55320. * @param samples Texture samples (default: 1)
  55321. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  55322. * @param fileName A name for for the downloaded file.
  55323. */
  55324. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  55325. }
  55326. }
  55327. declare module BABYLON {
  55328. /**
  55329. * A cursor which tracks a point on a path
  55330. */
  55331. export class PathCursor {
  55332. private path;
  55333. /**
  55334. * Stores path cursor callbacks for when an onchange event is triggered
  55335. */
  55336. private _onchange;
  55337. /**
  55338. * The value of the path cursor
  55339. */
  55340. value: number;
  55341. /**
  55342. * The animation array of the path cursor
  55343. */
  55344. animations: Animation[];
  55345. /**
  55346. * Initializes the path cursor
  55347. * @param path The path to track
  55348. */
  55349. constructor(path: Path2);
  55350. /**
  55351. * Gets the cursor point on the path
  55352. * @returns A point on the path cursor at the cursor location
  55353. */
  55354. getPoint(): Vector3;
  55355. /**
  55356. * Moves the cursor ahead by the step amount
  55357. * @param step The amount to move the cursor forward
  55358. * @returns This path cursor
  55359. */
  55360. moveAhead(step?: number): PathCursor;
  55361. /**
  55362. * Moves the cursor behind by the step amount
  55363. * @param step The amount to move the cursor back
  55364. * @returns This path cursor
  55365. */
  55366. moveBack(step?: number): PathCursor;
  55367. /**
  55368. * Moves the cursor by the step amount
  55369. * If the step amount is greater than one, an exception is thrown
  55370. * @param step The amount to move the cursor
  55371. * @returns This path cursor
  55372. */
  55373. move(step: number): PathCursor;
  55374. /**
  55375. * Ensures that the value is limited between zero and one
  55376. * @returns This path cursor
  55377. */
  55378. private ensureLimits;
  55379. /**
  55380. * Runs onchange callbacks on change (used by the animation engine)
  55381. * @returns This path cursor
  55382. */
  55383. private raiseOnChange;
  55384. /**
  55385. * Executes a function on change
  55386. * @param f A path cursor onchange callback
  55387. * @returns This path cursor
  55388. */
  55389. onchange(f: (cursor: PathCursor) => void): PathCursor;
  55390. }
  55391. }
  55392. declare module BABYLON {
  55393. /** @hidden */
  55394. export var blurPixelShader: {
  55395. name: string;
  55396. shader: string;
  55397. };
  55398. }
  55399. declare module BABYLON {
  55400. /** @hidden */
  55401. export var bones300Declaration: {
  55402. name: string;
  55403. shader: string;
  55404. };
  55405. }
  55406. declare module BABYLON {
  55407. /** @hidden */
  55408. export var instances300Declaration: {
  55409. name: string;
  55410. shader: string;
  55411. };
  55412. }
  55413. declare module BABYLON {
  55414. /** @hidden */
  55415. export var pointCloudVertexDeclaration: {
  55416. name: string;
  55417. shader: string;
  55418. };
  55419. }
  55420. // Mixins
  55421. interface Window {
  55422. mozIndexedDB: IDBFactory;
  55423. webkitIndexedDB: IDBFactory;
  55424. msIndexedDB: IDBFactory;
  55425. webkitURL: typeof URL;
  55426. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  55427. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  55428. WebGLRenderingContext: WebGLRenderingContext;
  55429. MSGesture: MSGesture;
  55430. CANNON: any;
  55431. AudioContext: AudioContext;
  55432. webkitAudioContext: AudioContext;
  55433. PointerEvent: any;
  55434. Math: Math;
  55435. Uint8Array: Uint8ArrayConstructor;
  55436. Float32Array: Float32ArrayConstructor;
  55437. mozURL: typeof URL;
  55438. msURL: typeof URL;
  55439. VRFrameData: any; // WebVR, from specs 1.1
  55440. DracoDecoderModule: any;
  55441. setImmediate(handler: (...args: any[]) => void): number;
  55442. }
  55443. interface HTMLCanvasElement {
  55444. requestPointerLock(): void;
  55445. msRequestPointerLock?(): void;
  55446. mozRequestPointerLock?(): void;
  55447. webkitRequestPointerLock?(): void;
  55448. /** Track wether a record is in progress */
  55449. isRecording: boolean;
  55450. /** Capture Stream method defined by some browsers */
  55451. captureStream(fps?: number): MediaStream;
  55452. }
  55453. interface CanvasRenderingContext2D {
  55454. msImageSmoothingEnabled: boolean;
  55455. }
  55456. interface MouseEvent {
  55457. mozMovementX: number;
  55458. mozMovementY: number;
  55459. webkitMovementX: number;
  55460. webkitMovementY: number;
  55461. msMovementX: number;
  55462. msMovementY: number;
  55463. }
  55464. interface Navigator {
  55465. mozGetVRDevices: (any: any) => any;
  55466. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55467. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55468. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55469. webkitGetGamepads(): Gamepad[];
  55470. msGetGamepads(): Gamepad[];
  55471. webkitGamepads(): Gamepad[];
  55472. }
  55473. interface HTMLVideoElement {
  55474. mozSrcObject: any;
  55475. }
  55476. interface Math {
  55477. fround(x: number): number;
  55478. imul(a: number, b: number): number;
  55479. }
  55480. interface WebGLProgram {
  55481. context?: WebGLRenderingContext;
  55482. vertexShader?: WebGLShader;
  55483. fragmentShader?: WebGLShader;
  55484. isParallelCompiled: boolean;
  55485. onCompiled?: () => void;
  55486. }
  55487. interface WebGLRenderingContext {
  55488. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  55489. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  55490. vertexAttribDivisor(index: number, divisor: number): void;
  55491. createVertexArray(): any;
  55492. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  55493. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  55494. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  55495. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  55496. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  55497. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  55498. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  55499. // Queries
  55500. createQuery(): WebGLQuery;
  55501. deleteQuery(query: WebGLQuery): void;
  55502. beginQuery(target: number, query: WebGLQuery): void;
  55503. endQuery(target: number): void;
  55504. getQueryParameter(query: WebGLQuery, pname: number): any;
  55505. getQuery(target: number, pname: number): any;
  55506. MAX_SAMPLES: number;
  55507. RGBA8: number;
  55508. READ_FRAMEBUFFER: number;
  55509. DRAW_FRAMEBUFFER: number;
  55510. UNIFORM_BUFFER: number;
  55511. HALF_FLOAT_OES: number;
  55512. RGBA16F: number;
  55513. RGBA32F: number;
  55514. R32F: number;
  55515. RG32F: number;
  55516. RGB32F: number;
  55517. R16F: number;
  55518. RG16F: number;
  55519. RGB16F: number;
  55520. RED: number;
  55521. RG: number;
  55522. R8: number;
  55523. RG8: number;
  55524. UNSIGNED_INT_24_8: number;
  55525. DEPTH24_STENCIL8: number;
  55526. /* Multiple Render Targets */
  55527. drawBuffers(buffers: number[]): void;
  55528. readBuffer(src: number): void;
  55529. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  55530. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  55531. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  55532. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  55533. // Occlusion Query
  55534. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  55535. ANY_SAMPLES_PASSED: number;
  55536. QUERY_RESULT_AVAILABLE: number;
  55537. QUERY_RESULT: number;
  55538. }
  55539. interface WebGLBuffer {
  55540. references: number;
  55541. capacity: number;
  55542. is32Bits: boolean;
  55543. }
  55544. interface WebGLProgram {
  55545. transformFeedback?: WebGLTransformFeedback | null; private _SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  55546. }
  55547. interface EXT_disjoint_timer_query {
  55548. QUERY_COUNTER_BITS_EXT: number;
  55549. TIME_ELAPSED_EXT: number;
  55550. TIMESTAMP_EXT: number;
  55551. GPU_DISJOINT_EXT: number;
  55552. QUERY_RESULT_EXT: number;
  55553. QUERY_RESULT_AVAILABLE_EXT: number;
  55554. queryCounterEXT(query: WebGLQuery, target: number): void;
  55555. createQueryEXT(): WebGLQuery;
  55556. beginQueryEXT(target: number, query: WebGLQuery): void;
  55557. endQueryEXT(target: number): void;
  55558. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  55559. deleteQueryEXT(query: WebGLQuery): void;
  55560. }
  55561. interface WebGLUniformLocation { currentState: any;
  55562. }
  55563. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  55564. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  55565. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  55566. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  55567. interface WebGLRenderingContext {
  55568. readonly RASTERIZER_DISCARD: number;
  55569. readonly DEPTH_COMPONENT24: number;
  55570. readonly TEXTURE_3D: number;
  55571. readonly TEXTURE_2D_ARRAY: number;
  55572. readonly TEXTURE_COMPARE_FUNC: number;
  55573. readonly TEXTURE_COMPARE_MODE: number;
  55574. readonly COMPARE_REF_TO_TEXTURE: number;
  55575. readonly TEXTURE_WRAP_R: number;
  55576. readonly HALF_FLOAT: number;
  55577. readonly RGB8: number;
  55578. readonly RED_INTEGER: number;
  55579. readonly RG_INTEGER: number;
  55580. readonly RGB_INTEGER: number;
  55581. readonly RGBA_INTEGER: number;
  55582. readonly R8_SNORM: number;
  55583. readonly RG8_SNORM: number;
  55584. readonly RGB8_SNORM: number;
  55585. readonly RGBA8_SNORM: number;
  55586. readonly R8I: number;
  55587. readonly RG8I: number;
  55588. readonly RGB8I: number;
  55589. readonly RGBA8I: number;
  55590. readonly R8UI: number;
  55591. readonly RG8UI: number;
  55592. readonly RGB8UI: number;
  55593. readonly RGBA8UI: number;
  55594. readonly R16I: number;
  55595. readonly RG16I: number;
  55596. readonly RGB16I: number;
  55597. readonly RGBA16I: number;
  55598. readonly R16UI: number;
  55599. readonly RG16UI: number;
  55600. readonly RGB16UI: number;
  55601. readonly RGBA16UI: number;
  55602. readonly R32I: number;
  55603. readonly RG32I: number;
  55604. readonly RGB32I: number;
  55605. readonly RGBA32I: number;
  55606. readonly R32UI: number;
  55607. readonly RG32UI: number;
  55608. readonly RGB32UI: number;
  55609. readonly RGBA32UI: number;
  55610. readonly RGB10_A2UI: number;
  55611. readonly R11F_G11F_B10F: number;
  55612. readonly RGB9_E5: number;
  55613. readonly RGB10_A2: number;
  55614. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  55615. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  55616. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  55617. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  55618. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  55619. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  55620. 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;
  55621. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  55622. readonly TRANSFORM_FEEDBACK: number;
  55623. readonly INTERLEAVED_ATTRIBS: number;
  55624. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  55625. createTransformFeedback(): WebGLTransformFeedback;
  55626. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  55627. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  55628. beginTransformFeedback(primitiveMode: number): void;
  55629. endTransformFeedback(): void;
  55630. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  55631. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55632. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55633. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55634. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  55635. }
  55636. interface ImageBitmap {
  55637. readonly width: number;
  55638. readonly height: number;
  55639. close(): void;
  55640. }
  55641. interface WebGLQuery extends WebGLObject {
  55642. }
  55643. declare var WebGLQuery: {
  55644. prototype: WebGLQuery;
  55645. new(): WebGLQuery;
  55646. };
  55647. interface WebGLSampler extends WebGLObject {
  55648. }
  55649. declare var WebGLSampler: {
  55650. prototype: WebGLSampler;
  55651. new(): WebGLSampler;
  55652. };
  55653. interface WebGLSync extends WebGLObject {
  55654. }
  55655. declare var WebGLSync: {
  55656. prototype: WebGLSync;
  55657. new(): WebGLSync;
  55658. };
  55659. interface WebGLTransformFeedback extends WebGLObject {
  55660. }
  55661. declare var WebGLTransformFeedback: {
  55662. prototype: WebGLTransformFeedback;
  55663. new(): WebGLTransformFeedback;
  55664. };
  55665. interface WebGLVertexArrayObject extends WebGLObject {
  55666. }
  55667. declare var WebGLVertexArrayObject: {
  55668. prototype: WebGLVertexArrayObject;
  55669. new(): WebGLVertexArrayObject;
  55670. };
  55671. // Type definitions for WebVR API
  55672. // Project: https://w3c.github.io/webvr/
  55673. // Definitions by: six a <https://github.com/lostfictions>
  55674. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  55675. interface VRDisplay extends EventTarget {
  55676. /**
  55677. * Dictionary of capabilities describing the VRDisplay.
  55678. */
  55679. readonly capabilities: VRDisplayCapabilities;
  55680. /**
  55681. * z-depth defining the far plane of the eye view frustum
  55682. * enables mapping of values in the render target depth
  55683. * attachment to scene coordinates. Initially set to 10000.0.
  55684. */
  55685. depthFar: number;
  55686. /**
  55687. * z-depth defining the near plane of the eye view frustum
  55688. * enables mapping of values in the render target depth
  55689. * attachment to scene coordinates. Initially set to 0.01.
  55690. */
  55691. depthNear: number;
  55692. /**
  55693. * An identifier for this distinct VRDisplay. Used as an
  55694. * association point in the Gamepad API.
  55695. */
  55696. readonly displayId: number;
  55697. /**
  55698. * A display name, a user-readable name identifying it.
  55699. */
  55700. readonly displayName: string;
  55701. readonly isConnected: boolean;
  55702. readonly isPresenting: boolean;
  55703. /**
  55704. * If this VRDisplay supports room-scale experiences, the optional
  55705. * stage attribute contains details on the room-scale parameters.
  55706. */
  55707. readonly stageParameters: VRStageParameters | null;
  55708. /**
  55709. * Passing the value returned by `requestAnimationFrame` to
  55710. * `cancelAnimationFrame` will unregister the callback.
  55711. * @param handle Define the hanle of the request to cancel
  55712. */
  55713. cancelAnimationFrame(handle: number): void;
  55714. /**
  55715. * Stops presenting to the VRDisplay.
  55716. * @returns a promise to know when it stopped
  55717. */
  55718. exitPresent(): Promise<void>;
  55719. /**
  55720. * Return the current VREyeParameters for the given eye.
  55721. * @param whichEye Define the eye we want the parameter for
  55722. * @returns the eye parameters
  55723. */
  55724. getEyeParameters(whichEye: string): VREyeParameters;
  55725. /**
  55726. * Populates the passed VRFrameData with the information required to render
  55727. * the current frame.
  55728. * @param frameData Define the data structure to populate
  55729. * @returns true if ok otherwise false
  55730. */
  55731. getFrameData(frameData: VRFrameData): boolean;
  55732. /**
  55733. * Get the layers currently being presented.
  55734. * @returns the list of VR layers
  55735. */
  55736. getLayers(): VRLayer[];
  55737. /**
  55738. * Return a VRPose containing the future predicted pose of the VRDisplay
  55739. * when the current frame will be presented. The value returned will not
  55740. * change until JavaScript has returned control to the browser.
  55741. *
  55742. * The VRPose will contain the position, orientation, velocity,
  55743. * and acceleration of each of these properties.
  55744. * @returns the pose object
  55745. */
  55746. getPose(): VRPose;
  55747. /**
  55748. * Return the current instantaneous pose of the VRDisplay, with no
  55749. * prediction applied.
  55750. * @returns the current instantaneous pose
  55751. */
  55752. getImmediatePose(): VRPose;
  55753. /**
  55754. * The callback passed to `requestAnimationFrame` will be called
  55755. * any time a new frame should be rendered. When the VRDisplay is
  55756. * presenting the callback will be called at the native refresh
  55757. * rate of the HMD. When not presenting this function acts
  55758. * identically to how window.requestAnimationFrame acts. Content should
  55759. * make no assumptions of frame rate or vsync behavior as the HMD runs
  55760. * asynchronously from other displays and at differing refresh rates.
  55761. * @param callback Define the eaction to run next frame
  55762. * @returns the request handle it
  55763. */
  55764. requestAnimationFrame(callback: FrameRequestCallback): number;
  55765. /**
  55766. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  55767. * Repeat calls while already presenting will update the VRLayers being displayed.
  55768. * @param layers Define the list of layer to present
  55769. * @returns a promise to know when the request has been fulfilled
  55770. */
  55771. requestPresent(layers: VRLayer[]): Promise<void>;
  55772. /**
  55773. * Reset the pose for this display, treating its current position and
  55774. * orientation as the "origin/zero" values. VRPose.position,
  55775. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  55776. * updated when calling resetPose(). This should be called in only
  55777. * sitting-space experiences.
  55778. */
  55779. resetPose(): void;
  55780. /**
  55781. * The VRLayer provided to the VRDisplay will be captured and presented
  55782. * in the HMD. Calling this function has the same effect on the source
  55783. * canvas as any other operation that uses its source image, and canvases
  55784. * created without preserveDrawingBuffer set to true will be cleared.
  55785. * @param pose Define the pose to submit
  55786. */
  55787. submitFrame(pose?: VRPose): void;
  55788. }
  55789. declare var VRDisplay: {
  55790. prototype: VRDisplay;
  55791. new(): VRDisplay;
  55792. };
  55793. interface VRLayer {
  55794. leftBounds?: number[] | Float32Array | null;
  55795. rightBounds?: number[] | Float32Array | null;
  55796. source?: HTMLCanvasElement | null;
  55797. }
  55798. interface VRDisplayCapabilities {
  55799. readonly canPresent: boolean;
  55800. readonly hasExternalDisplay: boolean;
  55801. readonly hasOrientation: boolean;
  55802. readonly hasPosition: boolean;
  55803. readonly maxLayers: number;
  55804. }
  55805. interface VREyeParameters {
  55806. /** @deprecated */
  55807. readonly fieldOfView: VRFieldOfView;
  55808. readonly offset: Float32Array;
  55809. readonly renderHeight: number;
  55810. readonly renderWidth: number;
  55811. }
  55812. interface VRFieldOfView {
  55813. readonly downDegrees: number;
  55814. readonly leftDegrees: number;
  55815. readonly rightDegrees: number;
  55816. readonly upDegrees: number;
  55817. }
  55818. interface VRFrameData {
  55819. readonly leftProjectionMatrix: Float32Array;
  55820. readonly leftViewMatrix: Float32Array;
  55821. readonly pose: VRPose;
  55822. readonly rightProjectionMatrix: Float32Array;
  55823. readonly rightViewMatrix: Float32Array;
  55824. readonly timestamp: number;
  55825. }
  55826. interface VRPose {
  55827. readonly angularAcceleration: Float32Array | null;
  55828. readonly angularVelocity: Float32Array | null;
  55829. readonly linearAcceleration: Float32Array | null;
  55830. readonly linearVelocity: Float32Array | null;
  55831. readonly orientation: Float32Array | null;
  55832. readonly position: Float32Array | null;
  55833. readonly timestamp: number;
  55834. }
  55835. interface VRStageParameters {
  55836. sittingToStandingTransform?: Float32Array;
  55837. sizeX?: number;
  55838. sizeY?: number;
  55839. }
  55840. interface Navigator {
  55841. getVRDisplays(): Promise<VRDisplay[]>;
  55842. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  55843. }
  55844. interface Window {
  55845. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  55846. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  55847. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  55848. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  55849. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  55850. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  55851. }
  55852. interface Gamepad {
  55853. readonly displayId: number;
  55854. }
  55855. interface XRDevice {
  55856. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  55857. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  55858. }
  55859. interface XRSession {
  55860. getInputSources(): Array<any>;
  55861. baseLayer: XRWebGLLayer;
  55862. requestFrameOfReference(type: string): Promise<void>;
  55863. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  55864. end(): Promise<void>;
  55865. requestAnimationFrame: Function;
  55866. addEventListener: Function;
  55867. }
  55868. interface XRSessionCreationOptions {
  55869. outputContext?: WebGLRenderingContext | null;
  55870. immersive?: boolean;
  55871. environmentIntegration?: boolean;
  55872. }
  55873. interface XRLayer {
  55874. getViewport: Function;
  55875. framebufferWidth: number;
  55876. framebufferHeight: number;
  55877. }
  55878. interface XRView {
  55879. projectionMatrix: Float32Array;
  55880. }
  55881. interface XRFrame {
  55882. getDevicePose: Function;
  55883. getInputPose: Function;
  55884. views: Array<XRView>;
  55885. baseLayer: XRLayer;
  55886. }
  55887. interface XRFrameOfReference {
  55888. }
  55889. interface XRWebGLLayer extends XRLayer {
  55890. framebuffer: WebGLFramebuffer;
  55891. }
  55892. declare var XRWebGLLayer: {
  55893. prototype: XRWebGLLayer;
  55894. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  55895. };
  55896. declare module BABYLON.GUI {
  55897. /**
  55898. * Class used to specific a value and its associated unit
  55899. */
  55900. export class ValueAndUnit {
  55901. /** defines the unit to store */
  55902. unit: number;
  55903. /** defines a boolean indicating if the value can be negative */
  55904. negativeValueAllowed: boolean;
  55905. private _value;
  55906. private _originalUnit;
  55907. /**
  55908. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  55909. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  55910. */
  55911. ignoreAdaptiveScaling: boolean;
  55912. /**
  55913. * Creates a new ValueAndUnit
  55914. * @param value defines the value to store
  55915. * @param unit defines the unit to store
  55916. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  55917. */
  55918. constructor(value: number,
  55919. /** defines the unit to store */
  55920. unit?: number,
  55921. /** defines a boolean indicating if the value can be negative */
  55922. negativeValueAllowed?: boolean);
  55923. /** Gets a boolean indicating if the value is a percentage */
  55924. readonly isPercentage: boolean;
  55925. /** Gets a boolean indicating if the value is store as pixel */
  55926. readonly isPixel: boolean;
  55927. /** Gets direct internal value */
  55928. readonly internalValue: number;
  55929. /**
  55930. * Gets value as pixel
  55931. * @param host defines the root host
  55932. * @param refValue defines the reference value for percentages
  55933. * @returns the value as pixel
  55934. */
  55935. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  55936. /**
  55937. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  55938. * @param value defines the value to store
  55939. * @param unit defines the unit to store
  55940. * @returns the current ValueAndUnit
  55941. */
  55942. updateInPlace(value: number, unit?: number): ValueAndUnit;
  55943. /**
  55944. * Gets the value accordingly to its unit
  55945. * @param host defines the root host
  55946. * @returns the value
  55947. */
  55948. getValue(host: AdvancedDynamicTexture): number;
  55949. /**
  55950. * Gets a string representation of the value
  55951. * @param host defines the root host
  55952. * @param decimals defines an optional number of decimals to display
  55953. * @returns a string
  55954. */
  55955. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  55956. /**
  55957. * Store a value parsed from a string
  55958. * @param source defines the source string
  55959. * @returns true if the value was successfully parsed
  55960. */
  55961. fromString(source: string | number): boolean;
  55962. private static _Regex;
  55963. private static _UNITMODE_PERCENTAGE;
  55964. private static _UNITMODE_PIXEL;
  55965. /** UNITMODE_PERCENTAGE */
  55966. static readonly UNITMODE_PERCENTAGE: number;
  55967. /** UNITMODE_PIXEL */
  55968. static readonly UNITMODE_PIXEL: number;
  55969. }
  55970. }
  55971. declare module BABYLON.GUI {
  55972. /**
  55973. * Define a style used by control to automatically setup properties based on a template.
  55974. * Only support font related properties so far
  55975. */
  55976. export class Style implements BABYLON.IDisposable {
  55977. private _fontFamily;
  55978. private _fontStyle;
  55979. private _fontWeight;
  55980. /** @hidden */ host: AdvancedDynamicTexture;
  55981. /** @hidden */ fontSize: ValueAndUnit;
  55982. /**
  55983. * BABYLON.Observable raised when the style values are changed
  55984. */
  55985. onChangedObservable: BABYLON.Observable<Style>;
  55986. /**
  55987. * Creates a new style object
  55988. * @param host defines the AdvancedDynamicTexture which hosts this style
  55989. */
  55990. constructor(host: AdvancedDynamicTexture);
  55991. /**
  55992. * Gets or sets the font size
  55993. */
  55994. fontSize: string | number;
  55995. /**
  55996. * Gets or sets the font family
  55997. */
  55998. fontFamily: string;
  55999. /**
  56000. * Gets or sets the font style
  56001. */
  56002. fontStyle: string;
  56003. /** Gets or sets font weight */
  56004. fontWeight: string;
  56005. /** Dispose all associated resources */
  56006. dispose(): void;
  56007. }
  56008. }
  56009. declare module BABYLON.GUI {
  56010. /**
  56011. * Class used to transport BABYLON.Vector2 information for pointer events
  56012. */
  56013. export class Vector2WithInfo extends BABYLON.Vector2 {
  56014. /** defines the current mouse button index */
  56015. buttonIndex: number;
  56016. /**
  56017. * Creates a new Vector2WithInfo
  56018. * @param source defines the vector2 data to transport
  56019. * @param buttonIndex defines the current mouse button index
  56020. */
  56021. constructor(source: BABYLON.Vector2,
  56022. /** defines the current mouse button index */
  56023. buttonIndex?: number);
  56024. }
  56025. /** Class used to provide 2D matrix features */
  56026. export class Matrix2D {
  56027. /** Gets the internal array of 6 floats used to store matrix data */
  56028. m: Float32Array;
  56029. /**
  56030. * Creates a new matrix
  56031. * @param m00 defines value for (0, 0)
  56032. * @param m01 defines value for (0, 1)
  56033. * @param m10 defines value for (1, 0)
  56034. * @param m11 defines value for (1, 1)
  56035. * @param m20 defines value for (2, 0)
  56036. * @param m21 defines value for (2, 1)
  56037. */
  56038. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  56039. /**
  56040. * Fills the matrix from direct values
  56041. * @param m00 defines value for (0, 0)
  56042. * @param m01 defines value for (0, 1)
  56043. * @param m10 defines value for (1, 0)
  56044. * @param m11 defines value for (1, 1)
  56045. * @param m20 defines value for (2, 0)
  56046. * @param m21 defines value for (2, 1)
  56047. * @returns the current modified matrix
  56048. */
  56049. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  56050. /**
  56051. * Gets matrix determinant
  56052. * @returns the determinant
  56053. */
  56054. determinant(): number;
  56055. /**
  56056. * Inverses the matrix and stores it in a target matrix
  56057. * @param result defines the target matrix
  56058. * @returns the current matrix
  56059. */
  56060. invertToRef(result: Matrix2D): Matrix2D;
  56061. /**
  56062. * Multiplies the current matrix with another one
  56063. * @param other defines the second operand
  56064. * @param result defines the target matrix
  56065. * @returns the current matrix
  56066. */
  56067. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  56068. /**
  56069. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  56070. * @param x defines the x coordinate to transform
  56071. * @param y defines the x coordinate to transform
  56072. * @param result defines the target vector2
  56073. * @returns the current matrix
  56074. */
  56075. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  56076. /**
  56077. * Creates an identity matrix
  56078. * @returns a new matrix
  56079. */
  56080. static Identity(): Matrix2D;
  56081. /**
  56082. * Creates a translation matrix and stores it in a target matrix
  56083. * @param x defines the x coordinate of the translation
  56084. * @param y defines the y coordinate of the translation
  56085. * @param result defines the target matrix
  56086. */
  56087. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  56088. /**
  56089. * Creates a scaling matrix and stores it in a target matrix
  56090. * @param x defines the x coordinate of the scaling
  56091. * @param y defines the y coordinate of the scaling
  56092. * @param result defines the target matrix
  56093. */
  56094. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  56095. /**
  56096. * Creates a rotation matrix and stores it in a target matrix
  56097. * @param angle defines the rotation angle
  56098. * @param result defines the target matrix
  56099. */
  56100. static RotationToRef(angle: number, result: Matrix2D): void;
  56101. private static _TempPreTranslationMatrix;
  56102. private static _TempPostTranslationMatrix;
  56103. private static _TempRotationMatrix;
  56104. private static _TempScalingMatrix;
  56105. private static _TempCompose0;
  56106. private static _TempCompose1;
  56107. private static _TempCompose2;
  56108. /**
  56109. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  56110. * @param tx defines the x coordinate of the translation
  56111. * @param ty defines the y coordinate of the translation
  56112. * @param angle defines the rotation angle
  56113. * @param scaleX defines the x coordinate of the scaling
  56114. * @param scaleY defines the y coordinate of the scaling
  56115. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  56116. * @param result defines the target matrix
  56117. */
  56118. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  56119. }
  56120. }
  56121. declare module BABYLON.GUI {
  56122. /**
  56123. * Class used to store 2D control sizes
  56124. */
  56125. export class Measure {
  56126. /** defines left coordinate */
  56127. left: number;
  56128. /** defines top coordinate */
  56129. top: number;
  56130. /** defines width dimension */
  56131. width: number;
  56132. /** defines height dimension */
  56133. height: number;
  56134. /**
  56135. * Creates a new measure
  56136. * @param left defines left coordinate
  56137. * @param top defines top coordinate
  56138. * @param width defines width dimension
  56139. * @param height defines height dimension
  56140. */
  56141. constructor(
  56142. /** defines left coordinate */
  56143. left: number,
  56144. /** defines top coordinate */
  56145. top: number,
  56146. /** defines width dimension */
  56147. width: number,
  56148. /** defines height dimension */
  56149. height: number);
  56150. /**
  56151. * Copy from another measure
  56152. * @param other defines the other measure to copy from
  56153. */
  56154. copyFrom(other: Measure): void;
  56155. /**
  56156. * Copy from a group of 4 floats
  56157. * @param left defines left coordinate
  56158. * @param top defines top coordinate
  56159. * @param width defines width dimension
  56160. * @param height defines height dimension
  56161. */
  56162. copyFromFloats(left: number, top: number, width: number, height: number): void;
  56163. /**
  56164. * Computes the axis aligned bounding box measure for two given measures
  56165. * @param a Input measure
  56166. * @param b Input measure
  56167. * @param result the resulting bounding measure
  56168. */
  56169. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  56170. /**
  56171. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  56172. * @param transform the matrix to transform the measure before computing the AABB
  56173. * @param result the resulting AABB
  56174. */
  56175. transformToRef(transform: Matrix2D, result: Measure): void;
  56176. /**
  56177. * Check equality between this measure and another one
  56178. * @param other defines the other measures
  56179. * @returns true if both measures are equals
  56180. */
  56181. isEqualsTo(other: Measure): boolean;
  56182. /**
  56183. * Creates an empty measure
  56184. * @returns a new measure
  56185. */
  56186. static Empty(): Measure;
  56187. }
  56188. }
  56189. declare module BABYLON.GUI {
  56190. /**
  56191. * Interface used to define a control that can receive focus
  56192. */
  56193. export interface IFocusableControl {
  56194. /**
  56195. * Function called when the control receives the focus
  56196. */
  56197. onFocus(): void;
  56198. /**
  56199. * Function called when the control loses the focus
  56200. */
  56201. onBlur(): void;
  56202. /**
  56203. * Function called to let the control handle keyboard events
  56204. * @param evt defines the current keyboard event
  56205. */
  56206. processKeyboard(evt: KeyboardEvent): void;
  56207. /**
  56208. * Function called to get the list of controls that should not steal the focus from this control
  56209. * @returns an array of controls
  56210. */
  56211. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  56212. }
  56213. /**
  56214. * Class used to create texture to support 2D GUI elements
  56215. * @see http://doc.babylonjs.com/how_to/gui
  56216. */
  56217. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  56218. private _isDirty;
  56219. private _renderObserver;
  56220. private _resizeObserver;
  56221. private _preKeyboardObserver;
  56222. private _pointerMoveObserver;
  56223. private _pointerObserver;
  56224. private _canvasPointerOutObserver;
  56225. private _background;
  56226. /** @hidden */ rootContainer: Container;
  56227. /** @hidden */ lastPickedControl: Control;
  56228. /** @hidden */ lastControlOver: {
  56229. [pointerId: number]: Control;
  56230. };
  56231. /** @hidden */ lastControlDown: {
  56232. [pointerId: number]: Control;
  56233. };
  56234. /** @hidden */ capturingControl: {
  56235. [pointerId: number]: Control;
  56236. };
  56237. /** @hidden */ shouldBlockPointer: boolean;
  56238. /** @hidden */ layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  56239. /** @hidden */ linkedControls: Control[];
  56240. private _isFullscreen;
  56241. private _fullscreenViewport;
  56242. private _idealWidth;
  56243. private _idealHeight;
  56244. private _useSmallestIdeal;
  56245. private _renderAtIdealSize;
  56246. private _focusedControl;
  56247. private _blockNextFocusCheck;
  56248. private _renderScale;
  56249. private _rootCanvas;
  56250. private _cursorChanged;
  56251. /**
  56252. * Define type to string to ensure compatibility across browsers
  56253. * Safari doesn't support DataTransfer constructor
  56254. */
  56255. private _clipboardData;
  56256. /**
  56257. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  56258. */
  56259. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  56260. /**
  56261. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  56262. */
  56263. onControlPickedObservable: BABYLON.Observable<Control>;
  56264. /**
  56265. * BABYLON.Observable event triggered before layout is evaluated
  56266. */
  56267. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56268. /**
  56269. * BABYLON.Observable event triggered after the layout was evaluated
  56270. */
  56271. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56272. /**
  56273. * BABYLON.Observable event triggered before the texture is rendered
  56274. */
  56275. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56276. /**
  56277. * BABYLON.Observable event triggered after the texture was rendered
  56278. */
  56279. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56280. /**
  56281. * Gets or sets a boolean defining if alpha is stored as premultiplied
  56282. */
  56283. premulAlpha: boolean;
  56284. /**
  56285. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  56286. * Useful when you want more antialiasing
  56287. */
  56288. renderScale: number;
  56289. /** Gets or sets the background color */
  56290. background: string;
  56291. /**
  56292. * Gets or sets the ideal width used to design controls.
  56293. * The GUI will then rescale everything accordingly
  56294. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56295. */
  56296. idealWidth: number;
  56297. /**
  56298. * Gets or sets the ideal height used to design controls.
  56299. * The GUI will then rescale everything accordingly
  56300. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56301. */
  56302. idealHeight: number;
  56303. /**
  56304. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  56305. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56306. */
  56307. useSmallestIdeal: boolean;
  56308. /**
  56309. * Gets or sets a boolean indicating if adaptive scaling must be used
  56310. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56311. */
  56312. renderAtIdealSize: boolean;
  56313. /**
  56314. * Gets the underlying layer used to render the texture when in fullscreen mode
  56315. */
  56316. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  56317. /**
  56318. * Gets the root container control
  56319. */
  56320. readonly rootContainer: Container;
  56321. /**
  56322. * Returns an array containing the root container.
  56323. * This is mostly used to let the Inspector introspects the ADT
  56324. * @returns an array containing the rootContainer
  56325. */
  56326. getChildren(): Array<Container>;
  56327. /**
  56328. * Will return all controls that are inside this texture
  56329. * @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
  56330. * @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
  56331. * @return all child controls
  56332. */
  56333. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  56334. /**
  56335. * Gets or sets the current focused control
  56336. */
  56337. focusedControl: BABYLON.Nullable<IFocusableControl>;
  56338. /**
  56339. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  56340. */
  56341. isForeground: boolean;
  56342. /**
  56343. * Gets or set information about clipboardData
  56344. */
  56345. clipboardData: string;
  56346. /**
  56347. * Creates a new AdvancedDynamicTexture
  56348. * @param name defines the name of the texture
  56349. * @param width defines the width of the texture
  56350. * @param height defines the height of the texture
  56351. * @param scene defines the hosting scene
  56352. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  56353. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  56354. */
  56355. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  56356. /**
  56357. * Get the current class name of the texture useful for serialization or dynamic coding.
  56358. * @returns "AdvancedDynamicTexture"
  56359. */
  56360. getClassName(): string;
  56361. /**
  56362. * Function used to execute a function on all controls
  56363. * @param func defines the function to execute
  56364. * @param container defines the container where controls belong. If null the root container will be used
  56365. */
  56366. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  56367. private _useInvalidateRectOptimization;
  56368. /**
  56369. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  56370. */
  56371. useInvalidateRectOptimization: boolean;
  56372. private _invalidatedRectangle;
  56373. /**
  56374. * Invalidates a rectangle area on the gui texture
  56375. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  56376. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  56377. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  56378. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  56379. */
  56380. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  56381. /**
  56382. * Marks the texture as dirty forcing a complete update
  56383. */
  56384. markAsDirty(): void;
  56385. /**
  56386. * Helper function used to create a new style
  56387. * @returns a new style
  56388. * @see http://doc.babylonjs.com/how_to/gui#styles
  56389. */
  56390. createStyle(): Style;
  56391. /**
  56392. * Adds a new control to the root container
  56393. * @param control defines the control to add
  56394. * @returns the current texture
  56395. */
  56396. addControl(control: Control): AdvancedDynamicTexture;
  56397. /**
  56398. * Removes a control from the root container
  56399. * @param control defines the control to remove
  56400. * @returns the current texture
  56401. */
  56402. removeControl(control: Control): AdvancedDynamicTexture;
  56403. /**
  56404. * Release all resources
  56405. */
  56406. dispose(): void;
  56407. private _onResize;
  56408. /** @hidden */ getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  56409. /**
  56410. * Get screen coordinates for a vector3
  56411. * @param position defines the position to project
  56412. * @param worldMatrix defines the world matrix to use
  56413. * @returns the projected position
  56414. */
  56415. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  56416. private _checkUpdate;
  56417. private _clearMeasure;
  56418. private _render;
  56419. /** @hidden */ changeCursor(cursor: string): void;
  56420. /** @hidden */ registerLastControlDown(control: Control, pointerId: number): void;
  56421. private _doPicking;
  56422. /** @hidden */ cleanControlAfterRemovalFromList(list: {
  56423. [pointerId: number]: Control;
  56424. }, control: Control): void;
  56425. /** @hidden */ cleanControlAfterRemoval(control: Control): void;
  56426. /** Attach to all scene events required to support pointer events */
  56427. attach(): void;
  56428. /** @hidden */
  56429. private onClipboardCopy;
  56430. /** @hidden */
  56431. private onClipboardCut;
  56432. /** @hidden */
  56433. private onClipboardPaste;
  56434. /**
  56435. * Register the clipboard Events onto the canvas
  56436. */
  56437. registerClipboardEvents(): void;
  56438. /**
  56439. * Unregister the clipboard Events from the canvas
  56440. */
  56441. unRegisterClipboardEvents(): void;
  56442. /**
  56443. * Connect the texture to a hosting mesh to enable interactions
  56444. * @param mesh defines the mesh to attach to
  56445. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  56446. */
  56447. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  56448. /**
  56449. * Move the focus to a specific control
  56450. * @param control defines the control which will receive the focus
  56451. */
  56452. moveFocusToControl(control: IFocusableControl): void;
  56453. private _manageFocus;
  56454. private _attachToOnPointerOut;
  56455. /**
  56456. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  56457. * @param mesh defines the mesh which will receive the texture
  56458. * @param width defines the texture width (1024 by default)
  56459. * @param height defines the texture height (1024 by default)
  56460. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  56461. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  56462. * @returns a new AdvancedDynamicTexture
  56463. */
  56464. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  56465. /**
  56466. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  56467. * In this mode the texture will rely on a layer for its rendering.
  56468. * This allows it to be treated like any other layer.
  56469. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  56470. * LayerMask is set through advancedTexture.layer.layerMask
  56471. * @param name defines name for the texture
  56472. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  56473. * @param scene defines the hsoting scene
  56474. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  56475. * @returns a new AdvancedDynamicTexture
  56476. */
  56477. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  56478. }
  56479. }
  56480. declare module BABYLON.GUI {
  56481. /**
  56482. * Root class used for all 2D controls
  56483. * @see http://doc.babylonjs.com/how_to/gui#controls
  56484. */
  56485. export class Control {
  56486. /** defines the name of the control */
  56487. name?: string | undefined;
  56488. /**
  56489. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  56490. */
  56491. static AllowAlphaInheritance: boolean;
  56492. private _alpha;
  56493. private _alphaSet;
  56494. private _zIndex;
  56495. /** @hidden */ host: AdvancedDynamicTexture;
  56496. /** Gets or sets the control parent */
  56497. parent: BABYLON.Nullable<Container>;
  56498. /** @hidden */ currentMeasure: Measure;
  56499. private _fontFamily;
  56500. private _fontStyle;
  56501. private _fontWeight;
  56502. private _fontSize;
  56503. private _font;
  56504. /** @hidden */ width: ValueAndUnit;
  56505. /** @hidden */ height: ValueAndUnit;
  56506. /** @hidden */
  56507. protected _fontOffset: {
  56508. ascent: number;
  56509. height: number;
  56510. descent: number;
  56511. };
  56512. private _color;
  56513. private _style;
  56514. private _styleObserver;
  56515. /** @hidden */
  56516. protected _horizontalAlignment: number;
  56517. /** @hidden */
  56518. protected _verticalAlignment: number;
  56519. /** @hidden */
  56520. protected _isDirty: boolean;
  56521. /** @hidden */
  56522. protected _wasDirty: boolean;
  56523. /** @hidden */ tempParentMeasure: Measure;
  56524. /** @hidden */ prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  56525. /** @hidden */
  56526. protected _cachedParentMeasure: Measure;
  56527. private _paddingLeft;
  56528. private _paddingRight;
  56529. private _paddingTop;
  56530. private _paddingBottom;
  56531. /** @hidden */ left: ValueAndUnit;
  56532. /** @hidden */ top: ValueAndUnit;
  56533. private _scaleX;
  56534. private _scaleY;
  56535. private _rotation;
  56536. private _transformCenterX;
  56537. private _transformCenterY;
  56538. /** @hidden */ transformMatrix: Matrix2D;
  56539. /** @hidden */
  56540. protected _invertTransformMatrix: Matrix2D;
  56541. /** @hidden */
  56542. protected _transformedPosition: BABYLON.Vector2;
  56543. private _isMatrixDirty;
  56544. private _cachedOffsetX;
  56545. private _cachedOffsetY;
  56546. private _isVisible;
  56547. private _isHighlighted;
  56548. /** @hidden */ linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  56549. private _fontSet;
  56550. private _dummyVector2;
  56551. private _downCount;
  56552. private _enterCount;
  56553. private _doNotRender;
  56554. private _downPointerIds;
  56555. protected _isEnabled: boolean;
  56556. protected _disabledColor: string;
  56557. /** @hidden */
  56558. protected _rebuildLayout: boolean;
  56559. /** @hidden */ isClipped: boolean;
  56560. /** @hidden */ tag: any;
  56561. /**
  56562. * 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
  56563. */
  56564. uniqueId: number;
  56565. /**
  56566. * Gets or sets an object used to store user defined information for the node
  56567. */
  56568. metadata: any;
  56569. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  56570. isHitTestVisible: boolean;
  56571. /** Gets or sets a boolean indicating if the control can block pointer events */
  56572. isPointerBlocker: boolean;
  56573. /** Gets or sets a boolean indicating if the control can be focusable */
  56574. isFocusInvisible: boolean;
  56575. /**
  56576. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  56577. * 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
  56578. */
  56579. clipChildren: boolean;
  56580. /**
  56581. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  56582. */
  56583. useBitmapCache: boolean;
  56584. private _cacheData;
  56585. private _shadowOffsetX;
  56586. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  56587. shadowOffsetX: number;
  56588. private _shadowOffsetY;
  56589. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  56590. shadowOffsetY: number;
  56591. private _shadowBlur;
  56592. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  56593. shadowBlur: number;
  56594. private _shadowColor;
  56595. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  56596. shadowColor: string;
  56597. /** Gets or sets the cursor to use when the control is hovered */
  56598. hoverCursor: string;
  56599. /** @hidden */
  56600. protected _linkOffsetX: ValueAndUnit;
  56601. /** @hidden */
  56602. protected _linkOffsetY: ValueAndUnit;
  56603. /** Gets the control type name */
  56604. readonly typeName: string;
  56605. /**
  56606. * Get the current class name of the control.
  56607. * @returns current class name
  56608. */
  56609. getClassName(): string;
  56610. /**
  56611. * An event triggered when the pointer move over the control.
  56612. */
  56613. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  56614. /**
  56615. * An event triggered when the pointer move out of the control.
  56616. */
  56617. onPointerOutObservable: BABYLON.Observable<Control>;
  56618. /**
  56619. * An event triggered when the pointer taps the control
  56620. */
  56621. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  56622. /**
  56623. * An event triggered when pointer up
  56624. */
  56625. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  56626. /**
  56627. * An event triggered when a control is clicked on
  56628. */
  56629. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  56630. /**
  56631. * An event triggered when pointer enters the control
  56632. */
  56633. onPointerEnterObservable: BABYLON.Observable<Control>;
  56634. /**
  56635. * An event triggered when the control is marked as dirty
  56636. */
  56637. onDirtyObservable: BABYLON.Observable<Control>;
  56638. /**
  56639. * An event triggered before drawing the control
  56640. */
  56641. onBeforeDrawObservable: BABYLON.Observable<Control>;
  56642. /**
  56643. * An event triggered after the control was drawn
  56644. */
  56645. onAfterDrawObservable: BABYLON.Observable<Control>;
  56646. /**
  56647. * Get the hosting AdvancedDynamicTexture
  56648. */
  56649. readonly host: AdvancedDynamicTexture;
  56650. /** Gets or set information about font offsets (used to render and align text) */
  56651. fontOffset: {
  56652. ascent: number;
  56653. height: number;
  56654. descent: number;
  56655. };
  56656. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  56657. alpha: number;
  56658. /**
  56659. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  56660. */
  56661. isHighlighted: boolean;
  56662. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  56663. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  56664. */
  56665. scaleX: number;
  56666. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  56667. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  56668. */
  56669. scaleY: number;
  56670. /** Gets or sets the rotation angle (0 by default)
  56671. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  56672. */
  56673. rotation: number;
  56674. /** Gets or sets the transformation center on Y axis (0 by default)
  56675. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  56676. */
  56677. transformCenterY: number;
  56678. /** Gets or sets the transformation center on X axis (0 by default)
  56679. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  56680. */
  56681. transformCenterX: number;
  56682. /**
  56683. * Gets or sets the horizontal alignment
  56684. * @see http://doc.babylonjs.com/how_to/gui#alignments
  56685. */
  56686. horizontalAlignment: number;
  56687. /**
  56688. * Gets or sets the vertical alignment
  56689. * @see http://doc.babylonjs.com/how_to/gui#alignments
  56690. */
  56691. verticalAlignment: number;
  56692. /**
  56693. * Gets or sets control width
  56694. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56695. */
  56696. width: string | number;
  56697. /**
  56698. * Gets control width in pixel
  56699. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56700. */
  56701. readonly widthInPixels: number;
  56702. /**
  56703. * Gets or sets control height
  56704. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56705. */
  56706. height: string | number;
  56707. /**
  56708. * Gets control height in pixel
  56709. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56710. */
  56711. readonly heightInPixels: number;
  56712. /** Gets or set font family */
  56713. fontFamily: string;
  56714. /** Gets or sets font style */
  56715. fontStyle: string;
  56716. /** Gets or sets font weight */
  56717. fontWeight: string;
  56718. /**
  56719. * Gets or sets style
  56720. * @see http://doc.babylonjs.com/how_to/gui#styles
  56721. */
  56722. style: BABYLON.Nullable<Style>;
  56723. /** @hidden */ protected readonly _isFontSizeInPercentage: boolean;
  56724. /** Gets font size in pixels */
  56725. readonly fontSizeInPixels: number;
  56726. /** Gets or sets font size */
  56727. fontSize: string | number;
  56728. /** Gets or sets foreground color */
  56729. color: string;
  56730. /** Gets or sets z index which is used to reorder controls on the z axis */
  56731. zIndex: number;
  56732. /** Gets or sets a boolean indicating if the control can be rendered */
  56733. notRenderable: boolean;
  56734. /** Gets or sets a boolean indicating if the control is visible */
  56735. isVisible: boolean;
  56736. /** Gets a boolean indicating that the control needs to update its rendering */
  56737. readonly isDirty: boolean;
  56738. /**
  56739. * Gets the current linked mesh (or null if none)
  56740. */
  56741. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  56742. /**
  56743. * Gets or sets a value indicating the padding to use on the left of the control
  56744. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56745. */
  56746. paddingLeft: string | number;
  56747. /**
  56748. * Gets a value indicating the padding in pixels to use on the left of the control
  56749. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56750. */
  56751. readonly paddingLeftInPixels: number;
  56752. /**
  56753. * Gets or sets a value indicating the padding to use on the right of the control
  56754. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56755. */
  56756. paddingRight: string | number;
  56757. /**
  56758. * Gets a value indicating the padding in pixels to use on the right of the control
  56759. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56760. */
  56761. readonly paddingRightInPixels: number;
  56762. /**
  56763. * Gets or sets a value indicating the padding to use on the top of the control
  56764. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56765. */
  56766. paddingTop: string | number;
  56767. /**
  56768. * Gets a value indicating the padding in pixels to use on the top of the control
  56769. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56770. */
  56771. readonly paddingTopInPixels: number;
  56772. /**
  56773. * Gets or sets a value indicating the padding to use on the bottom of the control
  56774. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56775. */
  56776. paddingBottom: string | number;
  56777. /**
  56778. * Gets a value indicating the padding in pixels to use on the bottom of the control
  56779. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56780. */
  56781. readonly paddingBottomInPixels: number;
  56782. /**
  56783. * Gets or sets a value indicating the left coordinate of the control
  56784. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56785. */
  56786. left: string | number;
  56787. /**
  56788. * Gets a value indicating the left coordinate in pixels of the control
  56789. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56790. */
  56791. readonly leftInPixels: number;
  56792. /**
  56793. * Gets or sets a value indicating the top coordinate of the control
  56794. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56795. */
  56796. top: string | number;
  56797. /**
  56798. * Gets a value indicating the top coordinate in pixels of the control
  56799. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56800. */
  56801. readonly topInPixels: number;
  56802. /**
  56803. * Gets or sets a value indicating the offset on X axis to the linked mesh
  56804. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  56805. */
  56806. linkOffsetX: string | number;
  56807. /**
  56808. * Gets a value indicating the offset in pixels on X axis to the linked mesh
  56809. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  56810. */
  56811. readonly linkOffsetXInPixels: number;
  56812. /**
  56813. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  56814. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  56815. */
  56816. linkOffsetY: string | number;
  56817. /**
  56818. * Gets a value indicating the offset in pixels on Y axis to the linked mesh
  56819. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  56820. */
  56821. readonly linkOffsetYInPixels: number;
  56822. /** Gets the center coordinate on X axis */
  56823. readonly centerX: number;
  56824. /** Gets the center coordinate on Y axis */
  56825. readonly centerY: number;
  56826. /** Gets or sets if control is Enabled*/
  56827. isEnabled: boolean;
  56828. /** Gets or sets background color of control if it's disabled*/
  56829. disabledColor: string;
  56830. /**
  56831. * Creates a new control
  56832. * @param name defines the name of the control
  56833. */
  56834. constructor(
  56835. /** defines the name of the control */
  56836. name?: string | undefined);
  56837. /** @hidden */
  56838. protected _getTypeName(): string;
  56839. /**
  56840. * Gets the first ascendant in the hierarchy of the given type
  56841. * @param className defines the required type
  56842. * @returns the ascendant or null if not found
  56843. */
  56844. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  56845. /** @hidden */ resetFontCache(): void;
  56846. /**
  56847. * Determines if a container is an ascendant of the current control
  56848. * @param container defines the container to look for
  56849. * @returns true if the container is one of the ascendant of the control
  56850. */
  56851. isAscendant(container: Control): boolean;
  56852. /**
  56853. * Gets coordinates in local control space
  56854. * @param globalCoordinates defines the coordinates to transform
  56855. * @returns the new coordinates in local space
  56856. */
  56857. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  56858. /**
  56859. * Gets coordinates in local control space
  56860. * @param globalCoordinates defines the coordinates to transform
  56861. * @param result defines the target vector2 where to store the result
  56862. * @returns the current control
  56863. */
  56864. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  56865. /**
  56866. * Gets coordinates in parent local control space
  56867. * @param globalCoordinates defines the coordinates to transform
  56868. * @returns the new coordinates in parent local space
  56869. */
  56870. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  56871. /**
  56872. * Move the current control to a vector3 position projected onto the screen.
  56873. * @param position defines the target position
  56874. * @param scene defines the hosting scene
  56875. */
  56876. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  56877. /** @hidden */ getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  56878. /**
  56879. * Will return all controls that have this control as ascendant
  56880. * @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
  56881. * @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
  56882. * @return all child controls
  56883. */
  56884. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  56885. /**
  56886. * Link current control with a target mesh
  56887. * @param mesh defines the mesh to link with
  56888. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  56889. */
  56890. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  56891. /** @hidden */ moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  56892. /** @hidden */ offsetLeft(offset: number): void;
  56893. /** @hidden */ offsetTop(offset: number): void;
  56894. /** @hidden */ markMatrixAsDirty(): void;
  56895. /** @hidden */ flagDescendantsAsMatrixDirty(): void;
  56896. /** @hidden */ intersectsRect(rect: Measure): boolean;
  56897. /** @hidden */
  56898. protected invalidateRect(): void;
  56899. /** @hidden */ markAsDirty(force?: boolean): void;
  56900. /** @hidden */ markAllAsDirty(): void;
  56901. /** @hidden */ link(host: AdvancedDynamicTexture): void;
  56902. /** @hidden */
  56903. protected _transform(context?: CanvasRenderingContext2D): void;
  56904. /** @hidden */ renderHighlight(context: CanvasRenderingContext2D): void;
  56905. /** @hidden */ renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  56906. /** @hidden */
  56907. protected _applyStates(context: CanvasRenderingContext2D): void;
  56908. /** @hidden */ layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  56909. /** @hidden */
  56910. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  56911. protected _evaluateClippingState(parentMeasure: Measure): void;
  56912. /** @hidden */ measure(): void;
  56913. /** @hidden */
  56914. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  56915. /** @hidden */
  56916. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  56917. /** @hidden */
  56918. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  56919. /** @hidden */
  56920. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  56921. private static _ClipMeasure;
  56922. private _tmpMeasureA;
  56923. private _clip;
  56924. /** @hidden */ render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  56925. /** @hidden */ draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  56926. /**
  56927. * Tests if a given coordinates belong to the current control
  56928. * @param x defines x coordinate to test
  56929. * @param y defines y coordinate to test
  56930. * @returns true if the coordinates are inside the control
  56931. */
  56932. contains(x: number, y: number): boolean;
  56933. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  56934. /** @hidden */ onPointerMove(target: Control, coordinates: BABYLON.Vector2): void;
  56935. /** @hidden */ onPointerEnter(target: Control): boolean;
  56936. /** @hidden */ onPointerOut(target: Control, force?: boolean): void;
  56937. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  56938. /** @hidden */ onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  56939. /** @hidden */ forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  56940. /** @hidden */ processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  56941. private _prepareFont;
  56942. /** Releases associated resources */
  56943. dispose(): void;
  56944. private static _HORIZONTAL_ALIGNMENT_LEFT;
  56945. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  56946. private static _HORIZONTAL_ALIGNMENT_CENTER;
  56947. private static _VERTICAL_ALIGNMENT_TOP;
  56948. private static _VERTICAL_ALIGNMENT_BOTTOM;
  56949. private static _VERTICAL_ALIGNMENT_CENTER;
  56950. /** HORIZONTAL_ALIGNMENT_LEFT */
  56951. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  56952. /** HORIZONTAL_ALIGNMENT_RIGHT */
  56953. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  56954. /** HORIZONTAL_ALIGNMENT_CENTER */
  56955. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  56956. /** VERTICAL_ALIGNMENT_TOP */
  56957. static readonly VERTICAL_ALIGNMENT_TOP: number;
  56958. /** VERTICAL_ALIGNMENT_BOTTOM */
  56959. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  56960. /** VERTICAL_ALIGNMENT_CENTER */
  56961. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  56962. private static _FontHeightSizes;
  56963. /** @hidden */ private static _GetFontOffset(font: string): {
  56964. ascent: number;
  56965. height: number;
  56966. descent: number;
  56967. };
  56968. /**
  56969. * Creates a stack panel that can be used to render headers
  56970. * @param control defines the control to associate with the header
  56971. * @param text defines the text of the header
  56972. * @param size defines the size of the header
  56973. * @param options defines options used to configure the header
  56974. * @returns a new StackPanel
  56975. * @ignore
  56976. * @hidden
  56977. */
  56978. static AddHeader: (control: Control, text: string, size: string | number, options: {
  56979. isHorizontal: boolean;
  56980. controlFirst: boolean;
  56981. }) => any;
  56982. /** @hidden */
  56983. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  56984. }
  56985. }
  56986. declare module BABYLON.GUI {
  56987. /**
  56988. * Root class for 2D containers
  56989. * @see http://doc.babylonjs.com/how_to/gui#containers
  56990. */
  56991. export class Container extends Control {
  56992. name?: string | undefined;
  56993. /** @hidden */
  56994. protected _children: Control[];
  56995. /** @hidden */
  56996. protected _measureForChildren: Measure;
  56997. /** @hidden */
  56998. protected _background: string;
  56999. /** @hidden */
  57000. protected _adaptWidthToChildren: boolean;
  57001. /** @hidden */
  57002. protected _adaptHeightToChildren: boolean;
  57003. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  57004. adaptHeightToChildren: boolean;
  57005. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  57006. adaptWidthToChildren: boolean;
  57007. /** Gets or sets background color */
  57008. background: string;
  57009. /** Gets the list of children */
  57010. readonly children: Control[];
  57011. /**
  57012. * Creates a new Container
  57013. * @param name defines the name of the container
  57014. */
  57015. constructor(name?: string | undefined);
  57016. protected _getTypeName(): string; flagDescendantsAsMatrixDirty(): void;
  57017. /**
  57018. * Gets a child using its name
  57019. * @param name defines the child name to look for
  57020. * @returns the child control if found
  57021. */
  57022. getChildByName(name: string): BABYLON.Nullable<Control>;
  57023. /**
  57024. * Gets a child using its type and its name
  57025. * @param name defines the child name to look for
  57026. * @param type defines the child type to look for
  57027. * @returns the child control if found
  57028. */
  57029. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  57030. /**
  57031. * Search for a specific control in children
  57032. * @param control defines the control to look for
  57033. * @returns true if the control is in child list
  57034. */
  57035. containsControl(control: Control): boolean;
  57036. /**
  57037. * Adds a new control to the current container
  57038. * @param control defines the control to add
  57039. * @returns the current container
  57040. */
  57041. addControl(control: BABYLON.Nullable<Control>): Container;
  57042. /**
  57043. * Removes all controls from the current container
  57044. * @returns the current container
  57045. */
  57046. clearControls(): Container;
  57047. /**
  57048. * Removes a control from the current container
  57049. * @param control defines the control to remove
  57050. * @returns the current container
  57051. */
  57052. removeControl(control: Control): Container;
  57053. /** @hidden */ reOrderControl(control: Control): void;
  57054. /** @hidden */ offsetLeft(offset: number): void;
  57055. /** @hidden */ offsetTop(offset: number): void;
  57056. /** @hidden */ markAllAsDirty(): void;
  57057. /** @hidden */
  57058. protected _localDraw(context: CanvasRenderingContext2D): void;
  57059. /** @hidden */ link(host: AdvancedDynamicTexture): void;
  57060. /** @hidden */
  57061. protected _beforeLayout(): void;
  57062. /** @hidden */
  57063. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57064. /** @hidden */ layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  57065. protected _postMeasure(): void;
  57066. /** @hidden */ draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  57067. /** @hidden */ getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  57068. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  57069. /** @hidden */
  57070. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57071. /** Releases associated resources */
  57072. dispose(): void;
  57073. }
  57074. }
  57075. declare module BABYLON.GUI {
  57076. /** Class used to create rectangle container */
  57077. export class Rectangle extends Container {
  57078. name?: string | undefined;
  57079. private _thickness;
  57080. private _cornerRadius;
  57081. /** Gets or sets border thickness */
  57082. thickness: number;
  57083. /** Gets or sets the corner radius angle */
  57084. cornerRadius: number;
  57085. /**
  57086. * Creates a new Rectangle
  57087. * @param name defines the control name
  57088. */
  57089. constructor(name?: string | undefined);
  57090. protected _getTypeName(): string;
  57091. protected _localDraw(context: CanvasRenderingContext2D): void;
  57092. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57093. private _drawRoundedRect;
  57094. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  57095. }
  57096. }
  57097. declare module BABYLON.GUI {
  57098. /**
  57099. * Enum that determines the text-wrapping mode to use.
  57100. */
  57101. export enum TextWrapping {
  57102. /**
  57103. * Clip the text when it's larger than Control.width; this is the default mode.
  57104. */
  57105. Clip = 0,
  57106. /**
  57107. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  57108. */
  57109. WordWrap = 1,
  57110. /**
  57111. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  57112. */
  57113. Ellipsis = 2
  57114. }
  57115. /**
  57116. * Class used to create text block control
  57117. */
  57118. export class TextBlock extends Control {
  57119. /**
  57120. * Defines the name of the control
  57121. */
  57122. name?: string | undefined;
  57123. private _text;
  57124. private _textWrapping;
  57125. private _textHorizontalAlignment;
  57126. private _textVerticalAlignment;
  57127. private _lines;
  57128. private _resizeToFit;
  57129. private _lineSpacing;
  57130. private _outlineWidth;
  57131. private _outlineColor;
  57132. /**
  57133. * An event triggered after the text is changed
  57134. */
  57135. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  57136. /**
  57137. * An event triggered after the text was broken up into lines
  57138. */
  57139. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  57140. /**
  57141. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  57142. */
  57143. readonly lines: any[];
  57144. /**
  57145. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  57146. */
  57147. /**
  57148. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  57149. */
  57150. resizeToFit: boolean;
  57151. /**
  57152. * Gets or sets a boolean indicating if text must be wrapped
  57153. */
  57154. /**
  57155. * Gets or sets a boolean indicating if text must be wrapped
  57156. */
  57157. textWrapping: TextWrapping | boolean;
  57158. /**
  57159. * Gets or sets text to display
  57160. */
  57161. /**
  57162. * Gets or sets text to display
  57163. */
  57164. text: string;
  57165. /**
  57166. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  57167. */
  57168. /**
  57169. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  57170. */
  57171. textHorizontalAlignment: number;
  57172. /**
  57173. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  57174. */
  57175. /**
  57176. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  57177. */
  57178. textVerticalAlignment: number;
  57179. /**
  57180. * Gets or sets line spacing value
  57181. */
  57182. /**
  57183. * Gets or sets line spacing value
  57184. */
  57185. lineSpacing: string | number;
  57186. /**
  57187. * Gets or sets outlineWidth of the text to display
  57188. */
  57189. /**
  57190. * Gets or sets outlineWidth of the text to display
  57191. */
  57192. outlineWidth: number;
  57193. /**
  57194. * Gets or sets outlineColor of the text to display
  57195. */
  57196. /**
  57197. * Gets or sets outlineColor of the text to display
  57198. */
  57199. outlineColor: string;
  57200. /**
  57201. * Creates a new TextBlock object
  57202. * @param name defines the name of the control
  57203. * @param text defines the text to display (emptry string by default)
  57204. */
  57205. constructor(
  57206. /**
  57207. * Defines the name of the control
  57208. */
  57209. name?: string | undefined, text?: string);
  57210. protected _getTypeName(): string;
  57211. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57212. private _drawText;
  57213. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  57214. protected _applyStates(context: CanvasRenderingContext2D): void;
  57215. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  57216. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  57217. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  57218. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  57219. protected _renderLines(context: CanvasRenderingContext2D): void;
  57220. /**
  57221. * Given a width constraint applied on the text block, find the expected height
  57222. * @returns expected height
  57223. */
  57224. computeExpectedHeight(): number;
  57225. dispose(): void;
  57226. }
  57227. }
  57228. declare module BABYLON.GUI {
  57229. /**
  57230. * Class used to create 2D images
  57231. */
  57232. export class Image extends Control {
  57233. name?: string | undefined;
  57234. private static _WorkingCanvas;
  57235. private _domImage;
  57236. private _imageWidth;
  57237. private _imageHeight;
  57238. private _loaded;
  57239. private _stretch;
  57240. private _source;
  57241. private _autoScale;
  57242. private _sourceLeft;
  57243. private _sourceTop;
  57244. private _sourceWidth;
  57245. private _sourceHeight;
  57246. private _cellWidth;
  57247. private _cellHeight;
  57248. private _cellId;
  57249. private _populateNinePatchSlicesFromImage;
  57250. private _sliceLeft;
  57251. private _sliceRight;
  57252. private _sliceTop;
  57253. private _sliceBottom;
  57254. private _detectPointerOnOpaqueOnly;
  57255. /**
  57256. * BABYLON.Observable notified when the content is loaded
  57257. */
  57258. onImageLoadedObservable: BABYLON.Observable<Image>;
  57259. /**
  57260. * Gets a boolean indicating that the content is loaded
  57261. */
  57262. readonly isLoaded: boolean;
  57263. /**
  57264. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  57265. */
  57266. populateNinePatchSlicesFromImage: boolean;
  57267. /**
  57268. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  57269. * Beware using this as this will comsume more memory as the image has to be stored twice
  57270. */
  57271. detectPointerOnOpaqueOnly: boolean;
  57272. /**
  57273. * Gets or sets the left value for slicing (9-patch)
  57274. */
  57275. sliceLeft: number;
  57276. /**
  57277. * Gets or sets the right value for slicing (9-patch)
  57278. */
  57279. sliceRight: number;
  57280. /**
  57281. * Gets or sets the top value for slicing (9-patch)
  57282. */
  57283. sliceTop: number;
  57284. /**
  57285. * Gets or sets the bottom value for slicing (9-patch)
  57286. */
  57287. sliceBottom: number;
  57288. /**
  57289. * Gets or sets the left coordinate in the source image
  57290. */
  57291. sourceLeft: number;
  57292. /**
  57293. * Gets or sets the top coordinate in the source image
  57294. */
  57295. sourceTop: number;
  57296. /**
  57297. * Gets or sets the width to capture in the source image
  57298. */
  57299. sourceWidth: number;
  57300. /**
  57301. * Gets or sets the height to capture in the source image
  57302. */
  57303. sourceHeight: number;
  57304. /**
  57305. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  57306. * @see http://doc.babylonjs.com/how_to/gui#image
  57307. */
  57308. autoScale: boolean;
  57309. /** Gets or sets the streching mode used by the image */
  57310. stretch: number;
  57311. /**
  57312. * Gets or sets the internal DOM image used to render the control
  57313. */
  57314. domImage: HTMLImageElement;
  57315. private _onImageLoaded;
  57316. private _extractNinePatchSliceDataFromImage;
  57317. /**
  57318. * Gets or sets image source url
  57319. */
  57320. source: BABYLON.Nullable<string>;
  57321. /**
  57322. * Gets or sets the cell width to use when animation sheet is enabled
  57323. * @see http://doc.babylonjs.com/how_to/gui#image
  57324. */
  57325. cellWidth: number;
  57326. /**
  57327. * Gets or sets the cell height to use when animation sheet is enabled
  57328. * @see http://doc.babylonjs.com/how_to/gui#image
  57329. */
  57330. cellHeight: number;
  57331. /**
  57332. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  57333. * @see http://doc.babylonjs.com/how_to/gui#image
  57334. */
  57335. cellId: number;
  57336. /**
  57337. * Creates a new Image
  57338. * @param name defines the control name
  57339. * @param url defines the image url
  57340. */
  57341. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  57342. /**
  57343. * Tests if a given coordinates belong to the current control
  57344. * @param x defines x coordinate to test
  57345. * @param y defines y coordinate to test
  57346. * @returns true if the coordinates are inside the control
  57347. */
  57348. contains(x: number, y: number): boolean;
  57349. protected _getTypeName(): string;
  57350. /** Force the control to synchronize with its content */
  57351. synchronizeSizeWithContent(): void;
  57352. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57353. private _prepareWorkingCanvasForOpaqueDetection;
  57354. private _drawImage; draw(context: CanvasRenderingContext2D): void;
  57355. private _renderCornerPatch;
  57356. private _renderNinePatch;
  57357. dispose(): void;
  57358. /** STRETCH_NONE */
  57359. static readonly STRETCH_NONE: number;
  57360. /** STRETCH_FILL */
  57361. static readonly STRETCH_FILL: number;
  57362. /** STRETCH_UNIFORM */
  57363. static readonly STRETCH_UNIFORM: number;
  57364. /** STRETCH_EXTEND */
  57365. static readonly STRETCH_EXTEND: number;
  57366. /** NINE_PATCH */
  57367. static readonly STRETCH_NINE_PATCH: number;
  57368. }
  57369. }
  57370. declare module BABYLON.GUI {
  57371. /**
  57372. * Class used to create 2D buttons
  57373. */
  57374. export class Button extends Rectangle {
  57375. name?: string | undefined;
  57376. /**
  57377. * Function called to generate a pointer enter animation
  57378. */
  57379. pointerEnterAnimation: () => void;
  57380. /**
  57381. * Function called to generate a pointer out animation
  57382. */
  57383. pointerOutAnimation: () => void;
  57384. /**
  57385. * Function called to generate a pointer down animation
  57386. */
  57387. pointerDownAnimation: () => void;
  57388. /**
  57389. * Function called to generate a pointer up animation
  57390. */
  57391. pointerUpAnimation: () => void;
  57392. private _image;
  57393. /**
  57394. * Returns the image part of the button (if any)
  57395. */
  57396. readonly image: BABYLON.Nullable<Image>;
  57397. private _textBlock;
  57398. /**
  57399. * Returns the image part of the button (if any)
  57400. */
  57401. readonly textBlock: BABYLON.Nullable<TextBlock>;
  57402. /**
  57403. * Creates a new Button
  57404. * @param name defines the name of the button
  57405. */
  57406. constructor(name?: string | undefined);
  57407. protected _getTypeName(): string;
  57408. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  57409. /** @hidden */ onPointerEnter(target: Control): boolean;
  57410. /** @hidden */ onPointerOut(target: Control, force?: boolean): void;
  57411. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  57412. /** @hidden */ onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  57413. /**
  57414. * Creates a new button made with an image and a text
  57415. * @param name defines the name of the button
  57416. * @param text defines the text of the button
  57417. * @param imageUrl defines the url of the image
  57418. * @returns a new Button
  57419. */
  57420. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  57421. /**
  57422. * Creates a new button made with an image
  57423. * @param name defines the name of the button
  57424. * @param imageUrl defines the url of the image
  57425. * @returns a new Button
  57426. */
  57427. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  57428. /**
  57429. * Creates a new button made with a text
  57430. * @param name defines the name of the button
  57431. * @param text defines the text of the button
  57432. * @returns a new Button
  57433. */
  57434. static CreateSimpleButton(name: string, text: string): Button;
  57435. /**
  57436. * Creates a new button made with an image and a centered text
  57437. * @param name defines the name of the button
  57438. * @param text defines the text of the button
  57439. * @param imageUrl defines the url of the image
  57440. * @returns a new Button
  57441. */
  57442. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  57443. }
  57444. }
  57445. declare module BABYLON.GUI {
  57446. /**
  57447. * Class used to create a 2D stack panel container
  57448. */
  57449. export class StackPanel extends Container {
  57450. name?: string | undefined;
  57451. private _isVertical;
  57452. private _manualWidth;
  57453. private _manualHeight;
  57454. private _doNotTrackManualChanges;
  57455. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  57456. isVertical: boolean;
  57457. /**
  57458. * Gets or sets panel width.
  57459. * This value should not be set when in horizontal mode as it will be computed automatically
  57460. */
  57461. width: string | number;
  57462. /**
  57463. * Gets or sets panel height.
  57464. * This value should not be set when in vertical mode as it will be computed automatically
  57465. */
  57466. height: string | number;
  57467. /**
  57468. * Creates a new StackPanel
  57469. * @param name defines control name
  57470. */
  57471. constructor(name?: string | undefined);
  57472. protected _getTypeName(): string;
  57473. /** @hidden */
  57474. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57475. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57476. protected _postMeasure(): void;
  57477. }
  57478. }
  57479. declare module BABYLON.GUI {
  57480. /**
  57481. * Class used to represent a 2D checkbox
  57482. */
  57483. export class Checkbox extends Control {
  57484. name?: string | undefined;
  57485. private _isChecked;
  57486. private _background;
  57487. private _checkSizeRatio;
  57488. private _thickness;
  57489. /** Gets or sets border thickness */
  57490. thickness: number;
  57491. /**
  57492. * BABYLON.Observable raised when isChecked property changes
  57493. */
  57494. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  57495. /** Gets or sets a value indicating the ratio between overall size and check size */
  57496. checkSizeRatio: number;
  57497. /** Gets or sets background color */
  57498. background: string;
  57499. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  57500. isChecked: boolean;
  57501. /**
  57502. * Creates a new CheckBox
  57503. * @param name defines the control name
  57504. */
  57505. constructor(name?: string | undefined);
  57506. protected _getTypeName(): string;
  57507. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  57508. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  57509. /**
  57510. * Utility function to easily create a checkbox with a header
  57511. * @param title defines the label to use for the header
  57512. * @param onValueChanged defines the callback to call when value changes
  57513. * @returns a StackPanel containing the checkbox and a textBlock
  57514. */
  57515. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  57516. }
  57517. }
  57518. declare module BABYLON.GUI {
  57519. /**
  57520. * Class used to store key control properties
  57521. */
  57522. export class KeyPropertySet {
  57523. /** Width */
  57524. width?: string;
  57525. /** Height */
  57526. height?: string;
  57527. /** Left padding */
  57528. paddingLeft?: string;
  57529. /** Right padding */
  57530. paddingRight?: string;
  57531. /** Top padding */
  57532. paddingTop?: string;
  57533. /** Bottom padding */
  57534. paddingBottom?: string;
  57535. /** Foreground color */
  57536. color?: string;
  57537. /** Background color */
  57538. background?: string;
  57539. }
  57540. /**
  57541. * Class used to create virtual keyboard
  57542. */
  57543. export class VirtualKeyboard extends StackPanel {
  57544. /** BABYLON.Observable raised when a key is pressed */
  57545. onKeyPressObservable: BABYLON.Observable<string>;
  57546. /** Gets or sets default key button width */
  57547. defaultButtonWidth: string;
  57548. /** Gets or sets default key button height */
  57549. defaultButtonHeight: string;
  57550. /** Gets or sets default key button left padding */
  57551. defaultButtonPaddingLeft: string;
  57552. /** Gets or sets default key button right padding */
  57553. defaultButtonPaddingRight: string;
  57554. /** Gets or sets default key button top padding */
  57555. defaultButtonPaddingTop: string;
  57556. /** Gets or sets default key button bottom padding */
  57557. defaultButtonPaddingBottom: string;
  57558. /** Gets or sets default key button foreground color */
  57559. defaultButtonColor: string;
  57560. /** Gets or sets default key button background color */
  57561. defaultButtonBackground: string;
  57562. /** Gets or sets shift button foreground color */
  57563. shiftButtonColor: string;
  57564. /** Gets or sets shift button thickness*/
  57565. selectedShiftThickness: number;
  57566. /** Gets shift key state */
  57567. shiftState: number;
  57568. protected _getTypeName(): string;
  57569. private _createKey;
  57570. /**
  57571. * Adds a new row of keys
  57572. * @param keys defines the list of keys to add
  57573. * @param propertySets defines the associated property sets
  57574. */
  57575. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  57576. /**
  57577. * Set the shift key to a specific state
  57578. * @param shiftState defines the new shift state
  57579. */
  57580. applyShiftState(shiftState: number): void;
  57581. private _currentlyConnectedInputText;
  57582. private _connectedInputTexts;
  57583. private _onKeyPressObserver;
  57584. /** Gets the input text control currently attached to the keyboard */
  57585. readonly connectedInputText: BABYLON.Nullable<InputText>;
  57586. /**
  57587. * Connects the keyboard with an input text control
  57588. *
  57589. * @param input defines the target control
  57590. */
  57591. connect(input: InputText): void;
  57592. /**
  57593. * Disconnects the keyboard from connected InputText controls
  57594. *
  57595. * @param input optionally defines a target control, otherwise all are disconnected
  57596. */
  57597. disconnect(input?: InputText): void;
  57598. private _removeConnectedInputObservables;
  57599. /**
  57600. * Release all resources
  57601. */
  57602. dispose(): void;
  57603. /**
  57604. * Creates a new keyboard using a default layout
  57605. *
  57606. * @param name defines control name
  57607. * @returns a new VirtualKeyboard
  57608. */
  57609. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  57610. }
  57611. }
  57612. declare module BABYLON.GUI {
  57613. /**
  57614. * Class used to create input text control
  57615. */
  57616. export class InputText extends Control implements IFocusableControl {
  57617. name?: string | undefined;
  57618. private _text;
  57619. private _placeholderText;
  57620. private _background;
  57621. private _focusedBackground;
  57622. private _focusedColor;
  57623. private _placeholderColor;
  57624. private _thickness;
  57625. private _margin;
  57626. private _autoStretchWidth;
  57627. private _maxWidth;
  57628. private _isFocused;
  57629. private _blinkTimeout;
  57630. private _blinkIsEven;
  57631. private _cursorOffset;
  57632. private _scrollLeft;
  57633. private _textWidth;
  57634. private _clickedCoordinate;
  57635. private _deadKey;
  57636. private _addKey;
  57637. private _currentKey;
  57638. private _isTextHighlightOn;
  57639. private _textHighlightColor;
  57640. private _highligherOpacity;
  57641. private _highlightedText;
  57642. private _startHighlightIndex;
  57643. private _endHighlightIndex;
  57644. private _cursorIndex;
  57645. private _onFocusSelectAll;
  57646. private _isPointerDown;
  57647. private _onClipboardObserver;
  57648. private _onPointerDblTapObserver;
  57649. /** @hidden */ connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  57650. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  57651. promptMessage: string;
  57652. /** BABYLON.Observable raised when the text changes */
  57653. onTextChangedObservable: BABYLON.Observable<InputText>;
  57654. /** BABYLON.Observable raised just before an entered character is to be added */
  57655. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  57656. /** BABYLON.Observable raised when the control gets the focus */
  57657. onFocusObservable: BABYLON.Observable<InputText>;
  57658. /** BABYLON.Observable raised when the control loses the focus */
  57659. onBlurObservable: BABYLON.Observable<InputText>;
  57660. /**Observable raised when the text is highlighted */
  57661. onTextHighlightObservable: BABYLON.Observable<InputText>;
  57662. /**Observable raised when copy event is triggered */
  57663. onTextCopyObservable: BABYLON.Observable<InputText>;
  57664. /** BABYLON.Observable raised when cut event is triggered */
  57665. onTextCutObservable: BABYLON.Observable<InputText>;
  57666. /** BABYLON.Observable raised when paste event is triggered */
  57667. onTextPasteObservable: BABYLON.Observable<InputText>;
  57668. /** BABYLON.Observable raised when a key event was processed */
  57669. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  57670. /** Gets or sets the maximum width allowed by the control */
  57671. maxWidth: string | number;
  57672. /** Gets the maximum width allowed by the control in pixels */
  57673. readonly maxWidthInPixels: number;
  57674. /** Gets or sets the text highlighter transparency; default: 0.4 */
  57675. highligherOpacity: number;
  57676. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  57677. onFocusSelectAll: boolean;
  57678. /** Gets or sets the text hightlight color */
  57679. textHighlightColor: string;
  57680. /** Gets or sets control margin */
  57681. margin: string;
  57682. /** Gets control margin in pixels */
  57683. readonly marginInPixels: number;
  57684. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  57685. autoStretchWidth: boolean;
  57686. /** Gets or sets border thickness */
  57687. thickness: number;
  57688. /** Gets or sets the background color when focused */
  57689. focusedBackground: string;
  57690. /** Gets or sets the background color when focused */
  57691. focusedColor: string;
  57692. /** Gets or sets the background color */
  57693. background: string;
  57694. /** Gets or sets the placeholder color */
  57695. placeholderColor: string;
  57696. /** Gets or sets the text displayed when the control is empty */
  57697. placeholderText: string;
  57698. /** Gets or sets the dead key flag */
  57699. deadKey: boolean;
  57700. /** Gets or sets the highlight text */
  57701. highlightedText: string;
  57702. /** Gets or sets if the current key should be added */
  57703. addKey: boolean;
  57704. /** Gets or sets the value of the current key being entered */
  57705. currentKey: string;
  57706. /** Gets or sets the text displayed in the control */
  57707. text: string;
  57708. /** Gets or sets control width */
  57709. width: string | number;
  57710. /**
  57711. * Creates a new InputText
  57712. * @param name defines the control name
  57713. * @param text defines the text of the control
  57714. */
  57715. constructor(name?: string | undefined, text?: string);
  57716. /** @hidden */
  57717. onBlur(): void;
  57718. /** @hidden */
  57719. onFocus(): void;
  57720. protected _getTypeName(): string;
  57721. /**
  57722. * Function called to get the list of controls that should not steal the focus from this control
  57723. * @returns an array of controls
  57724. */
  57725. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  57726. /** @hidden */
  57727. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  57728. /** @hidden */
  57729. private _updateValueFromCursorIndex;
  57730. /** @hidden */
  57731. private _processDblClick;
  57732. /** @hidden */
  57733. private _selectAllText;
  57734. /**
  57735. * Handles the keyboard event
  57736. * @param evt Defines the KeyboardEvent
  57737. */
  57738. processKeyboard(evt: KeyboardEvent): void;
  57739. /** @hidden */
  57740. private _onCopyText;
  57741. /** @hidden */
  57742. private _onCutText;
  57743. /** @hidden */
  57744. private _onPasteText; draw(context: CanvasRenderingContext2D): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; onPointerMove(target: Control, coordinates: BABYLON.Vector2): void; onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  57745. protected _beforeRenderText(text: string): string;
  57746. dispose(): void;
  57747. }
  57748. }
  57749. declare module BABYLON.GUI {
  57750. /**
  57751. * Class used to create a 2D grid container
  57752. */
  57753. export class Grid extends Container {
  57754. name?: string | undefined;
  57755. private _rowDefinitions;
  57756. private _columnDefinitions;
  57757. private _cells;
  57758. private _childControls;
  57759. /**
  57760. * Gets the number of columns
  57761. */
  57762. readonly columnCount: number;
  57763. /**
  57764. * Gets the number of rows
  57765. */
  57766. readonly rowCount: number;
  57767. /** Gets the list of children */
  57768. readonly children: Control[];
  57769. /**
  57770. * Gets the definition of a specific row
  57771. * @param index defines the index of the row
  57772. * @returns the row definition
  57773. */
  57774. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  57775. /**
  57776. * Gets the definition of a specific column
  57777. * @param index defines the index of the column
  57778. * @returns the column definition
  57779. */
  57780. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  57781. /**
  57782. * Adds a new row to the grid
  57783. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  57784. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  57785. * @returns the current grid
  57786. */
  57787. addRowDefinition(height: number, isPixel?: boolean): Grid;
  57788. /**
  57789. * Adds a new column to the grid
  57790. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  57791. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  57792. * @returns the current grid
  57793. */
  57794. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  57795. /**
  57796. * Update a row definition
  57797. * @param index defines the index of the row to update
  57798. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  57799. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  57800. * @returns the current grid
  57801. */
  57802. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  57803. /**
  57804. * Update a column definition
  57805. * @param index defines the index of the column to update
  57806. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  57807. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  57808. * @returns the current grid
  57809. */
  57810. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  57811. /**
  57812. * Gets the list of children stored in a specific cell
  57813. * @param row defines the row to check
  57814. * @param column defines the column to check
  57815. * @returns the list of controls
  57816. */
  57817. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  57818. /**
  57819. * Gets a string representing the child cell info (row x column)
  57820. * @param child defines the control to get info from
  57821. * @returns a string containing the child cell info (row x column)
  57822. */
  57823. getChildCellInfo(child: Control): string;
  57824. private _removeCell;
  57825. private _offsetCell;
  57826. /**
  57827. * Remove a column definition at specified index
  57828. * @param index defines the index of the column to remove
  57829. * @returns the current grid
  57830. */
  57831. removeColumnDefinition(index: number): Grid;
  57832. /**
  57833. * Remove a row definition at specified index
  57834. * @param index defines the index of the row to remove
  57835. * @returns the current grid
  57836. */
  57837. removeRowDefinition(index: number): Grid;
  57838. /**
  57839. * Adds a new control to the current grid
  57840. * @param control defines the control to add
  57841. * @param row defines the row where to add the control (0 by default)
  57842. * @param column defines the column where to add the control (0 by default)
  57843. * @returns the current grid
  57844. */
  57845. addControl(control: Control, row?: number, column?: number): Grid;
  57846. /**
  57847. * Removes a control from the current container
  57848. * @param control defines the control to remove
  57849. * @returns the current container
  57850. */
  57851. removeControl(control: Control): Container;
  57852. /**
  57853. * Creates a new Grid
  57854. * @param name defines control name
  57855. */
  57856. constructor(name?: string | undefined);
  57857. protected _getTypeName(): string;
  57858. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  57859. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; flagDescendantsAsMatrixDirty(): void; renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  57860. /** Releases associated resources */
  57861. dispose(): void;
  57862. }
  57863. }
  57864. declare module BABYLON.GUI {
  57865. /** Class used to create color pickers */
  57866. export class ColorPicker extends Control {
  57867. name?: string | undefined;
  57868. private static _Epsilon;
  57869. private _colorWheelCanvas;
  57870. private _value;
  57871. private _tmpColor;
  57872. private _pointerStartedOnSquare;
  57873. private _pointerStartedOnWheel;
  57874. private _squareLeft;
  57875. private _squareTop;
  57876. private _squareSize;
  57877. private _h;
  57878. private _s;
  57879. private _v;
  57880. /**
  57881. * BABYLON.Observable raised when the value changes
  57882. */
  57883. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  57884. /** Gets or sets the color of the color picker */
  57885. value: BABYLON.Color3;
  57886. /**
  57887. * Gets or sets control width
  57888. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57889. */
  57890. width: string | number;
  57891. /**
  57892. * Gets or sets control height
  57893. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57894. */
  57895. /** Gets or sets control height */
  57896. height: string | number;
  57897. /** Gets or sets control size */
  57898. size: string | number;
  57899. /**
  57900. * Creates a new ColorPicker
  57901. * @param name defines the control name
  57902. */
  57903. constructor(name?: string | undefined);
  57904. protected _getTypeName(): string;
  57905. /** @hidden */
  57906. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57907. private _updateSquareProps;
  57908. private _drawGradientSquare;
  57909. private _drawCircle;
  57910. private _createColorWheelCanvas;
  57911. private _RGBtoHSV;
  57912. private _HSVtoRGB;
  57913. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  57914. private _pointerIsDown;
  57915. private _updateValueFromPointer;
  57916. private _isPointOnSquare;
  57917. private _isPointOnWheel; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; onPointerMove(target: Control, coordinates: BABYLON.Vector2): void; onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  57918. /**
  57919. * This function expands the color picker by creating a color picker dialog with manual
  57920. * color value input and the ability to save colors into an array to be used later in
  57921. * subsequent launches of the dialogue.
  57922. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  57923. * @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.
  57924. * @returns picked color as a hex string and the saved colors array as hex strings.
  57925. */
  57926. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  57927. pickerWidth?: string;
  57928. pickerHeight?: string;
  57929. headerHeight?: string;
  57930. lastColor?: string;
  57931. swatchLimit?: number;
  57932. numSwatchesPerLine?: number;
  57933. savedColors?: Array<string>;
  57934. }): Promise<{
  57935. savedColors?: string[];
  57936. pickedColor: string;
  57937. }>;
  57938. }
  57939. }
  57940. declare module BABYLON.GUI {
  57941. /** Class used to create 2D ellipse containers */
  57942. export class Ellipse extends Container {
  57943. name?: string | undefined;
  57944. private _thickness;
  57945. /** Gets or sets border thickness */
  57946. thickness: number;
  57947. /**
  57948. * Creates a new Ellipse
  57949. * @param name defines the control name
  57950. */
  57951. constructor(name?: string | undefined);
  57952. protected _getTypeName(): string;
  57953. protected _localDraw(context: CanvasRenderingContext2D): void;
  57954. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57955. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  57956. }
  57957. }
  57958. declare module BABYLON.GUI {
  57959. /**
  57960. * Class used to create a password control
  57961. */
  57962. export class InputPassword extends InputText {
  57963. protected _beforeRenderText(text: string): string;
  57964. }
  57965. }
  57966. declare module BABYLON.GUI {
  57967. /** Class used to render 2D lines */
  57968. export class Line extends Control {
  57969. name?: string | undefined;
  57970. private _lineWidth;
  57971. private _x1;
  57972. private _y1;
  57973. private _x2;
  57974. private _y2;
  57975. private _dash;
  57976. private _connectedControl;
  57977. private _connectedControlDirtyObserver;
  57978. /** Gets or sets the dash pattern */
  57979. dash: Array<number>;
  57980. /** Gets or sets the control connected with the line end */
  57981. connectedControl: Control;
  57982. /** Gets or sets start coordinates on X axis */
  57983. x1: string | number;
  57984. /** Gets or sets start coordinates on Y axis */
  57985. y1: string | number;
  57986. /** Gets or sets end coordinates on X axis */
  57987. x2: string | number;
  57988. /** Gets or sets end coordinates on Y axis */
  57989. y2: string | number;
  57990. /** Gets or sets line width */
  57991. lineWidth: number;
  57992. /** Gets or sets horizontal alignment */
  57993. horizontalAlignment: number;
  57994. /** Gets or sets vertical alignment */
  57995. verticalAlignment: number;
  57996. private readonly _effectiveX2;
  57997. private readonly _effectiveY2;
  57998. /**
  57999. * Creates a new Line
  58000. * @param name defines the control name
  58001. */
  58002. constructor(name?: string | undefined);
  58003. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void; measure(): void;
  58004. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58005. /**
  58006. * Move one end of the line given 3D cartesian coordinates.
  58007. * @param position Targeted world position
  58008. * @param scene BABYLON.Scene
  58009. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  58010. */
  58011. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  58012. /**
  58013. * Move one end of the line to a position in screen absolute space.
  58014. * @param projectedPosition Position in screen absolute space (X, Y)
  58015. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  58016. */ moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  58017. }
  58018. }
  58019. declare module BABYLON.GUI {
  58020. /**
  58021. * Class used to store a point for a MultiLine object.
  58022. * The point can be pure 2D coordinates, a mesh or a control
  58023. */
  58024. export class MultiLinePoint {
  58025. private _multiLine;
  58026. private _x;
  58027. private _y;
  58028. private _control;
  58029. private _mesh;
  58030. private _controlObserver;
  58031. private _meshObserver;
  58032. /** @hidden */ point: BABYLON.Vector2;
  58033. /**
  58034. * Creates a new MultiLinePoint
  58035. * @param multiLine defines the source MultiLine object
  58036. */
  58037. constructor(multiLine: MultiLine);
  58038. /** Gets or sets x coordinate */
  58039. x: string | number;
  58040. /** Gets or sets y coordinate */
  58041. y: string | number;
  58042. /** Gets or sets the control associated with this point */
  58043. control: BABYLON.Nullable<Control>;
  58044. /** Gets or sets the mesh associated with this point */
  58045. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  58046. /** Resets links */
  58047. resetLinks(): void;
  58048. /**
  58049. * Gets a translation vector
  58050. * @returns the translation vector
  58051. */
  58052. translate(): BABYLON.Vector2;
  58053. private _translatePoint;
  58054. /** Release associated resources */
  58055. dispose(): void;
  58056. }
  58057. }
  58058. declare module BABYLON.GUI {
  58059. /**
  58060. * Class used to create multi line control
  58061. */
  58062. export class MultiLine extends Control {
  58063. name?: string | undefined;
  58064. private _lineWidth;
  58065. private _dash;
  58066. private _points;
  58067. private _minX;
  58068. private _minY;
  58069. private _maxX;
  58070. private _maxY;
  58071. /**
  58072. * Creates a new MultiLine
  58073. * @param name defines the control name
  58074. */
  58075. constructor(name?: string | undefined);
  58076. /** Gets or sets dash pattern */
  58077. dash: Array<number>;
  58078. /**
  58079. * Gets point stored at specified index
  58080. * @param index defines the index to look for
  58081. * @returns the requested point if found
  58082. */
  58083. getAt(index: number): MultiLinePoint;
  58084. /** Function called when a point is updated */
  58085. onPointUpdate: () => void;
  58086. /**
  58087. * Adds new points to the point collection
  58088. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  58089. * @returns the list of created MultiLinePoint
  58090. */
  58091. add(...items: (AbstractMesh | Control | {
  58092. x: string | number;
  58093. y: string | number;
  58094. })[]): MultiLinePoint[];
  58095. /**
  58096. * Adds a new point to the point collection
  58097. * @param item defines the item (mesh, control or 2d coordiantes) to add
  58098. * @returns the created MultiLinePoint
  58099. */
  58100. push(item?: (AbstractMesh | Control | {
  58101. x: string | number;
  58102. y: string | number;
  58103. })): MultiLinePoint;
  58104. /**
  58105. * Remove a specific value or point from the active point collection
  58106. * @param value defines the value or point to remove
  58107. */
  58108. remove(value: number | MultiLinePoint): void;
  58109. /**
  58110. * Resets this object to initial state (no point)
  58111. */
  58112. reset(): void;
  58113. /**
  58114. * Resets all links
  58115. */
  58116. resetLinks(): void;
  58117. /** Gets or sets line width */
  58118. lineWidth: number;
  58119. horizontalAlignment: number;
  58120. verticalAlignment: number;
  58121. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  58122. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; measure(): void;
  58123. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58124. dispose(): void;
  58125. }
  58126. }
  58127. declare module BABYLON.GUI {
  58128. /**
  58129. * Class used to create radio button controls
  58130. */
  58131. export class RadioButton extends Control {
  58132. name?: string | undefined;
  58133. private _isChecked;
  58134. private _background;
  58135. private _checkSizeRatio;
  58136. private _thickness;
  58137. /** Gets or sets border thickness */
  58138. thickness: number;
  58139. /** Gets or sets group name */
  58140. group: string;
  58141. /** BABYLON.Observable raised when isChecked is changed */
  58142. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  58143. /** Gets or sets a value indicating the ratio between overall size and check size */
  58144. checkSizeRatio: number;
  58145. /** Gets or sets background color */
  58146. background: string;
  58147. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  58148. isChecked: boolean;
  58149. /**
  58150. * Creates a new RadioButton
  58151. * @param name defines the control name
  58152. */
  58153. constructor(name?: string | undefined);
  58154. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  58155. /**
  58156. * Utility function to easily create a radio button with a header
  58157. * @param title defines the label to use for the header
  58158. * @param group defines the group to use for the radio button
  58159. * @param isChecked defines the initial state of the radio button
  58160. * @param onValueChanged defines the callback to call when value changes
  58161. * @returns a StackPanel containing the radio button and a textBlock
  58162. */
  58163. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  58164. }
  58165. }
  58166. declare module BABYLON.GUI {
  58167. /**
  58168. * Class used to create slider controls
  58169. */
  58170. export class BaseSlider extends Control {
  58171. name?: string | undefined;
  58172. protected _thumbWidth: ValueAndUnit;
  58173. private _minimum;
  58174. private _maximum;
  58175. private _value;
  58176. private _isVertical;
  58177. protected _barOffset: ValueAndUnit;
  58178. private _isThumbClamped;
  58179. protected _displayThumb: boolean;
  58180. private _step;
  58181. protected _effectiveBarOffset: number;
  58182. protected _renderLeft: number;
  58183. protected _renderTop: number;
  58184. protected _renderWidth: number;
  58185. protected _renderHeight: number;
  58186. protected _backgroundBoxLength: number;
  58187. protected _backgroundBoxThickness: number;
  58188. protected _effectiveThumbThickness: number;
  58189. /** BABYLON.Observable raised when the sldier value changes */
  58190. onValueChangedObservable: BABYLON.Observable<number>;
  58191. /** Gets or sets a boolean indicating if the thumb must be rendered */
  58192. displayThumb: boolean;
  58193. /** Gets or sets a step to apply to values (0 by default) */
  58194. step: number;
  58195. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  58196. barOffset: string | number;
  58197. /** Gets main bar offset in pixels*/
  58198. readonly barOffsetInPixels: number;
  58199. /** Gets or sets thumb width */
  58200. thumbWidth: string | number;
  58201. /** Gets thumb width in pixels */
  58202. readonly thumbWidthInPixels: number;
  58203. /** Gets or sets minimum value */
  58204. minimum: number;
  58205. /** Gets or sets maximum value */
  58206. maximum: number;
  58207. /** Gets or sets current value */
  58208. value: number;
  58209. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  58210. isVertical: boolean;
  58211. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  58212. isThumbClamped: boolean;
  58213. /**
  58214. * Creates a new BaseSlider
  58215. * @param name defines the control name
  58216. */
  58217. constructor(name?: string | undefined);
  58218. protected _getTypeName(): string;
  58219. protected _getThumbPosition(): number;
  58220. protected _getThumbThickness(type: string): number;
  58221. protected _prepareRenderingData(type: string): void;
  58222. private _pointerIsDown;
  58223. /** @hidden */
  58224. protected _updateValueFromPointer(x: number, y: number): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; onPointerMove(target: Control, coordinates: BABYLON.Vector2): void; onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  58225. }
  58226. }
  58227. declare module BABYLON.GUI {
  58228. /**
  58229. * Class used to create slider controls
  58230. */
  58231. export class Slider extends BaseSlider {
  58232. name?: string | undefined;
  58233. private _background;
  58234. private _borderColor;
  58235. private _isThumbCircle;
  58236. protected _displayValueBar: boolean;
  58237. /** Gets or sets a boolean indicating if the value bar must be rendered */
  58238. displayValueBar: boolean;
  58239. /** Gets or sets border color */
  58240. borderColor: string;
  58241. /** Gets or sets background color */
  58242. background: string;
  58243. /** Gets or sets a boolean indicating if the thumb should be round or square */
  58244. isThumbCircle: boolean;
  58245. /**
  58246. * Creates a new Slider
  58247. * @param name defines the control name
  58248. */
  58249. constructor(name?: string | undefined);
  58250. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  58251. }
  58252. }
  58253. declare module BABYLON.GUI {
  58254. /** Class used to create a RadioGroup
  58255. * which contains groups of radio buttons
  58256. */
  58257. export class SelectorGroup {
  58258. /** name of SelectorGroup */
  58259. name: string;
  58260. private _groupPanel;
  58261. private _selectors;
  58262. private _groupHeader;
  58263. /**
  58264. * Creates a new SelectorGroup
  58265. * @param name of group, used as a group heading
  58266. */
  58267. constructor(
  58268. /** name of SelectorGroup */
  58269. name: string);
  58270. /** Gets the groupPanel of the SelectorGroup */
  58271. readonly groupPanel: StackPanel;
  58272. /** Gets the selectors array */
  58273. readonly selectors: StackPanel[];
  58274. /** Gets and sets the group header */
  58275. header: string;
  58276. /** @hidden */
  58277. private _addGroupHeader;
  58278. /** @hidden*/ getSelector(selectorNb: number): StackPanel | undefined;
  58279. /** Removes the selector at the given position
  58280. * @param selectorNb the position of the selector within the group
  58281. */
  58282. removeSelector(selectorNb: number): void;
  58283. }
  58284. /** Class used to create a CheckboxGroup
  58285. * which contains groups of checkbox buttons
  58286. */
  58287. export class CheckboxGroup extends SelectorGroup {
  58288. /** Adds a checkbox as a control
  58289. * @param text is the label for the selector
  58290. * @param func is the function called when the Selector is checked
  58291. * @param checked is true when Selector is checked
  58292. */
  58293. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  58294. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  58295. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  58296. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  58297. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  58298. }
  58299. /** Class used to create a RadioGroup
  58300. * which contains groups of radio buttons
  58301. */
  58302. export class RadioGroup extends SelectorGroup {
  58303. private _selectNb;
  58304. /** Adds a radio button as a control
  58305. * @param label is the label for the selector
  58306. * @param func is the function called when the Selector is checked
  58307. * @param checked is true when Selector is checked
  58308. */
  58309. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  58310. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  58311. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  58312. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  58313. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  58314. }
  58315. /** Class used to create a SliderGroup
  58316. * which contains groups of slider buttons
  58317. */
  58318. export class SliderGroup extends SelectorGroup {
  58319. /**
  58320. * Adds a slider to the SelectorGroup
  58321. * @param label is the label for the SliderBar
  58322. * @param func is the function called when the Slider moves
  58323. * @param unit is a string describing the units used, eg degrees or metres
  58324. * @param min is the minimum value for the Slider
  58325. * @param max is the maximum value for the Slider
  58326. * @param value is the start value for the Slider between min and max
  58327. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  58328. */
  58329. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  58330. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  58331. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  58332. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  58333. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  58334. }
  58335. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  58336. * @see http://doc.babylonjs.com/how_to/selector
  58337. */
  58338. export class SelectionPanel extends Rectangle {
  58339. /** name of SelectionPanel */
  58340. name: string;
  58341. /** an array of SelectionGroups */
  58342. groups: SelectorGroup[];
  58343. private _panel;
  58344. private _buttonColor;
  58345. private _buttonBackground;
  58346. private _headerColor;
  58347. private _barColor;
  58348. private _barHeight;
  58349. private _spacerHeight;
  58350. private _labelColor;
  58351. private _groups;
  58352. private _bars;
  58353. /**
  58354. * Creates a new SelectionPanel
  58355. * @param name of SelectionPanel
  58356. * @param groups is an array of SelectionGroups
  58357. */
  58358. constructor(
  58359. /** name of SelectionPanel */
  58360. name: string,
  58361. /** an array of SelectionGroups */
  58362. groups?: SelectorGroup[]);
  58363. protected _getTypeName(): string;
  58364. /** Gets or sets the headerColor */
  58365. headerColor: string;
  58366. private _setHeaderColor;
  58367. /** Gets or sets the button color */
  58368. buttonColor: string;
  58369. private _setbuttonColor;
  58370. /** Gets or sets the label color */
  58371. labelColor: string;
  58372. private _setLabelColor;
  58373. /** Gets or sets the button background */
  58374. buttonBackground: string;
  58375. private _setButtonBackground;
  58376. /** Gets or sets the color of separator bar */
  58377. barColor: string;
  58378. private _setBarColor;
  58379. /** Gets or sets the height of separator bar */
  58380. barHeight: string;
  58381. private _setBarHeight;
  58382. /** Gets or sets the height of spacers*/
  58383. spacerHeight: string;
  58384. private _setSpacerHeight;
  58385. /** Adds a bar between groups */
  58386. private _addSpacer;
  58387. /** Add a group to the selection panel
  58388. * @param group is the selector group to add
  58389. */
  58390. addGroup(group: SelectorGroup): void;
  58391. /** Remove the group from the given position
  58392. * @param groupNb is the position of the group in the list
  58393. */
  58394. removeGroup(groupNb: number): void;
  58395. /** Change a group header label
  58396. * @param label is the new group header label
  58397. * @param groupNb is the number of the group to relabel
  58398. * */
  58399. setHeaderName(label: string, groupNb: number): void;
  58400. /** Change selector label to the one given
  58401. * @param label is the new selector label
  58402. * @param groupNb is the number of the groupcontaining the selector
  58403. * @param selectorNb is the number of the selector within a group to relabel
  58404. * */
  58405. relabel(label: string, groupNb: number, selectorNb: number): void;
  58406. /** For a given group position remove the selector at the given position
  58407. * @param groupNb is the number of the group to remove the selector from
  58408. * @param selectorNb is the number of the selector within the group
  58409. */
  58410. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  58411. /** For a given group position of correct type add a checkbox button
  58412. * @param groupNb is the number of the group to remove the selector from
  58413. * @param label is the label for the selector
  58414. * @param func is the function called when the Selector is checked
  58415. * @param checked is true when Selector is checked
  58416. */
  58417. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  58418. /** For a given group position of correct type add a radio button
  58419. * @param groupNb is the number of the group to remove the selector from
  58420. * @param label is the label for the selector
  58421. * @param func is the function called when the Selector is checked
  58422. * @param checked is true when Selector is checked
  58423. */
  58424. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  58425. /**
  58426. * For a given slider group add a slider
  58427. * @param groupNb is the number of the group to add the slider to
  58428. * @param label is the label for the Slider
  58429. * @param func is the function called when the Slider moves
  58430. * @param unit is a string describing the units used, eg degrees or metres
  58431. * @param min is the minimum value for the Slider
  58432. * @param max is the maximum value for the Slider
  58433. * @param value is the start value for the Slider between min and max
  58434. * @param onVal is the function used to format the value displayed, eg radians to degrees
  58435. */
  58436. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  58437. }
  58438. }
  58439. declare module BABYLON.GUI {
  58440. /**
  58441. * Class used to hold a the container for ScrollViewer
  58442. * @hidden
  58443. */
  58444. export class _ScrollViewerWindow extends Container {
  58445. parentClientWidth: number;
  58446. parentClientHeight: number;
  58447. /**
  58448. * Creates a new ScrollViewerWindow
  58449. * @param name of ScrollViewerWindow
  58450. */
  58451. constructor(name?: string);
  58452. protected _getTypeName(): string;
  58453. /** @hidden */
  58454. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58455. protected _postMeasure(): void;
  58456. }
  58457. }
  58458. declare module BABYLON.GUI {
  58459. /**
  58460. * Class used to create slider controls
  58461. */
  58462. export class ScrollBar extends BaseSlider {
  58463. name?: string | undefined;
  58464. private _background;
  58465. private _borderColor;
  58466. private _thumbMeasure;
  58467. /** Gets or sets border color */
  58468. borderColor: string;
  58469. /** Gets or sets background color */
  58470. background: string;
  58471. /**
  58472. * Creates a new Slider
  58473. * @param name defines the control name
  58474. */
  58475. constructor(name?: string | undefined);
  58476. protected _getTypeName(): string;
  58477. protected _getThumbThickness(): number; draw(context: CanvasRenderingContext2D): void;
  58478. private _first;
  58479. private _originX;
  58480. private _originY;
  58481. /** @hidden */
  58482. protected _updateValueFromPointer(x: number, y: number): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  58483. }
  58484. }
  58485. declare module BABYLON.GUI {
  58486. /**
  58487. * Class used to hold a viewer window and sliders in a grid
  58488. */
  58489. export class ScrollViewer extends Rectangle {
  58490. private _grid;
  58491. private _horizontalBarSpace;
  58492. private _verticalBarSpace;
  58493. private _dragSpace;
  58494. private _horizontalBar;
  58495. private _verticalBar;
  58496. private _barColor;
  58497. private _barBackground;
  58498. private _barSize;
  58499. private _endLeft;
  58500. private _endTop;
  58501. private _window;
  58502. private _pointerIsOver;
  58503. private _wheelPrecision;
  58504. private _onPointerObserver;
  58505. private _clientWidth;
  58506. private _clientHeight;
  58507. /**
  58508. * Gets the horizontal scrollbar
  58509. */
  58510. readonly horizontalBar: ScrollBar;
  58511. /**
  58512. * Gets the vertical scrollbar
  58513. */
  58514. readonly verticalBar: ScrollBar;
  58515. /**
  58516. * Adds a new control to the current container
  58517. * @param control defines the control to add
  58518. * @returns the current container
  58519. */
  58520. addControl(control: BABYLON.Nullable<Control>): Container;
  58521. /**
  58522. * Removes a control from the current container
  58523. * @param control defines the control to remove
  58524. * @returns the current container
  58525. */
  58526. removeControl(control: Control): Container;
  58527. /** Gets the list of children */
  58528. readonly children: Control[]; flagDescendantsAsMatrixDirty(): void;
  58529. /**
  58530. * Creates a new ScrollViewer
  58531. * @param name of ScrollViewer
  58532. */
  58533. constructor(name?: string);
  58534. /** Reset the scroll viewer window to initial size */
  58535. resetWindow(): void;
  58536. protected _getTypeName(): string;
  58537. private _buildClientSizes;
  58538. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58539. protected _postMeasure(): void;
  58540. /**
  58541. * Gets or sets the mouse wheel precision
  58542. * from 0 to 1 with a default value of 0.05
  58543. * */
  58544. wheelPrecision: number;
  58545. /** Gets or sets the bar color */
  58546. barColor: string;
  58547. /** Gets or sets the size of the bar */
  58548. barSize: number;
  58549. /** Gets or sets the bar background */
  58550. barBackground: string;
  58551. /** @hidden */
  58552. private _updateScroller; link(host: AdvancedDynamicTexture): void;
  58553. /** @hidden */
  58554. private _attachWheel; renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  58555. /** Releases associated resources */
  58556. dispose(): void;
  58557. }
  58558. }
  58559. declare module BABYLON.GUI {
  58560. /** Class used to render a grid */
  58561. export class DisplayGrid extends Control {
  58562. name?: string | undefined;
  58563. private _cellWidth;
  58564. private _cellHeight;
  58565. private _minorLineTickness;
  58566. private _minorLineColor;
  58567. private _majorLineTickness;
  58568. private _majorLineColor;
  58569. private _majorLineFrequency;
  58570. private _background;
  58571. private _displayMajorLines;
  58572. private _displayMinorLines;
  58573. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  58574. displayMinorLines: boolean;
  58575. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  58576. displayMajorLines: boolean;
  58577. /** Gets or sets background color (Black by default) */
  58578. background: string;
  58579. /** Gets or sets the width of each cell (20 by default) */
  58580. cellWidth: number;
  58581. /** Gets or sets the height of each cell (20 by default) */
  58582. cellHeight: number;
  58583. /** Gets or sets the tickness of minor lines (1 by default) */
  58584. minorLineTickness: number;
  58585. /** Gets or sets the color of minor lines (DarkGray by default) */
  58586. minorLineColor: string;
  58587. /** Gets or sets the tickness of major lines (2 by default) */
  58588. majorLineTickness: number;
  58589. /** Gets or sets the color of major lines (White by default) */
  58590. majorLineColor: string;
  58591. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  58592. majorLineFrequency: number;
  58593. /**
  58594. * Creates a new GridDisplayRectangle
  58595. * @param name defines the control name
  58596. */
  58597. constructor(name?: string | undefined); draw(context: CanvasRenderingContext2D): void;
  58598. protected _getTypeName(): string;
  58599. }
  58600. }
  58601. declare module BABYLON.GUI {
  58602. /**
  58603. * Class used to create slider controls based on images
  58604. */
  58605. export class ImageBasedSlider extends BaseSlider {
  58606. name?: string | undefined;
  58607. private _backgroundImage;
  58608. private _thumbImage;
  58609. private _valueBarImage;
  58610. private _tempMeasure;
  58611. displayThumb: boolean;
  58612. /**
  58613. * Gets or sets the image used to render the background
  58614. */
  58615. backgroundImage: Image;
  58616. /**
  58617. * Gets or sets the image used to render the value bar
  58618. */
  58619. valueBarImage: Image;
  58620. /**
  58621. * Gets or sets the image used to render the thumb
  58622. */
  58623. thumbImage: Image;
  58624. /**
  58625. * Creates a new ImageBasedSlider
  58626. * @param name defines the control name
  58627. */
  58628. constructor(name?: string | undefined);
  58629. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  58630. }
  58631. }
  58632. declare module BABYLON.GUI {
  58633. /**
  58634. * Forcing an export so that this code will execute
  58635. * @hidden
  58636. */
  58637. const name = "Statics";
  58638. }
  58639. declare module BABYLON.GUI {
  58640. /**
  58641. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  58642. */
  58643. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  58644. /**
  58645. * Define the instrumented AdvancedDynamicTexture.
  58646. */
  58647. texture: AdvancedDynamicTexture;
  58648. private _captureRenderTime;
  58649. private _renderTime;
  58650. private _captureLayoutTime;
  58651. private _layoutTime;
  58652. private _onBeginRenderObserver;
  58653. private _onEndRenderObserver;
  58654. private _onBeginLayoutObserver;
  58655. private _onEndLayoutObserver;
  58656. /**
  58657. * Gets the perf counter used to capture render time
  58658. */
  58659. readonly renderTimeCounter: BABYLON.PerfCounter;
  58660. /**
  58661. * Gets the perf counter used to capture layout time
  58662. */
  58663. readonly layoutTimeCounter: BABYLON.PerfCounter;
  58664. /**
  58665. * Enable or disable the render time capture
  58666. */
  58667. captureRenderTime: boolean;
  58668. /**
  58669. * Enable or disable the layout time capture
  58670. */
  58671. captureLayoutTime: boolean;
  58672. /**
  58673. * Instantiates a new advanced dynamic texture instrumentation.
  58674. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  58675. * @param texture Defines the AdvancedDynamicTexture to instrument
  58676. */
  58677. constructor(
  58678. /**
  58679. * Define the instrumented AdvancedDynamicTexture.
  58680. */
  58681. texture: AdvancedDynamicTexture);
  58682. /**
  58683. * Dispose and release associated resources.
  58684. */
  58685. dispose(): void;
  58686. }
  58687. }
  58688. declare module BABYLON.GUI {
  58689. /**
  58690. * Class used to create containers for controls
  58691. */
  58692. export class Container3D extends Control3D {
  58693. private _blockLayout;
  58694. /**
  58695. * Gets the list of child controls
  58696. */
  58697. protected _children: Control3D[];
  58698. /**
  58699. * Gets the list of child controls
  58700. */
  58701. readonly children: Array<Control3D>;
  58702. /**
  58703. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  58704. * This is helpful to optimize layout operation when adding multiple children in a row
  58705. */
  58706. blockLayout: boolean;
  58707. /**
  58708. * Creates a new container
  58709. * @param name defines the container name
  58710. */
  58711. constructor(name?: string);
  58712. /**
  58713. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  58714. * @returns the current container
  58715. */
  58716. updateLayout(): Container3D;
  58717. /**
  58718. * Gets a boolean indicating if the given control is in the children of this control
  58719. * @param control defines the control to check
  58720. * @returns true if the control is in the child list
  58721. */
  58722. containsControl(control: Control3D): boolean;
  58723. /**
  58724. * Adds a control to the children of this control
  58725. * @param control defines the control to add
  58726. * @returns the current container
  58727. */
  58728. addControl(control: Control3D): Container3D;
  58729. /**
  58730. * This function will be called everytime a new control is added
  58731. */
  58732. protected _arrangeChildren(): void;
  58733. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  58734. /**
  58735. * Removes a control from the children of this control
  58736. * @param control defines the control to remove
  58737. * @returns the current container
  58738. */
  58739. removeControl(control: Control3D): Container3D;
  58740. protected _getTypeName(): string;
  58741. /**
  58742. * Releases all associated resources
  58743. */
  58744. dispose(): void;
  58745. /** Control rotation will remain unchanged */
  58746. static readonly UNSET_ORIENTATION: number;
  58747. /** Control will rotate to make it look at sphere central axis */
  58748. static readonly FACEORIGIN_ORIENTATION: number;
  58749. /** Control will rotate to make it look back at sphere central axis */
  58750. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  58751. /** Control will rotate to look at z axis (0, 0, 1) */
  58752. static readonly FACEFORWARD_ORIENTATION: number;
  58753. /** Control will rotate to look at negative z axis (0, 0, -1) */
  58754. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  58755. }
  58756. }
  58757. declare module BABYLON.GUI {
  58758. /**
  58759. * Class used to manage 3D user interface
  58760. * @see http://doc.babylonjs.com/how_to/gui3d
  58761. */
  58762. export class GUI3DManager implements BABYLON.IDisposable {
  58763. private _scene;
  58764. private _sceneDisposeObserver;
  58765. private _utilityLayer;
  58766. private _rootContainer;
  58767. private _pointerObserver;
  58768. private _pointerOutObserver;
  58769. /** @hidden */ lastPickedControl: Control3D;
  58770. /** @hidden */ lastControlOver: {
  58771. [pointerId: number]: Control3D;
  58772. };
  58773. /** @hidden */ lastControlDown: {
  58774. [pointerId: number]: Control3D;
  58775. };
  58776. /**
  58777. * BABYLON.Observable raised when the point picked by the pointer events changed
  58778. */
  58779. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  58780. /** @hidden */ sharedMaterials: {
  58781. [key: string]: BABYLON.Material;
  58782. };
  58783. /** Gets the hosting scene */
  58784. readonly scene: BABYLON.Scene;
  58785. /** Gets associated utility layer */
  58786. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  58787. /**
  58788. * Creates a new GUI3DManager
  58789. * @param scene
  58790. */
  58791. constructor(scene?: BABYLON.Scene);
  58792. private _handlePointerOut;
  58793. private _doPicking;
  58794. /**
  58795. * Gets the root container
  58796. */
  58797. readonly rootContainer: Container3D;
  58798. /**
  58799. * Gets a boolean indicating if the given control is in the root child list
  58800. * @param control defines the control to check
  58801. * @returns true if the control is in the root child list
  58802. */
  58803. containsControl(control: Control3D): boolean;
  58804. /**
  58805. * Adds a control to the root child list
  58806. * @param control defines the control to add
  58807. * @returns the current manager
  58808. */
  58809. addControl(control: Control3D): GUI3DManager;
  58810. /**
  58811. * Removes a control from the root child list
  58812. * @param control defines the control to remove
  58813. * @returns the current container
  58814. */
  58815. removeControl(control: Control3D): GUI3DManager;
  58816. /**
  58817. * Releases all associated resources
  58818. */
  58819. dispose(): void;
  58820. }
  58821. }
  58822. declare module BABYLON.GUI {
  58823. /**
  58824. * Class used to transport BABYLON.Vector3 information for pointer events
  58825. */
  58826. export class Vector3WithInfo extends BABYLON.Vector3 {
  58827. /** defines the current mouse button index */
  58828. buttonIndex: number;
  58829. /**
  58830. * Creates a new Vector3WithInfo
  58831. * @param source defines the vector3 data to transport
  58832. * @param buttonIndex defines the current mouse button index
  58833. */
  58834. constructor(source: BABYLON.Vector3,
  58835. /** defines the current mouse button index */
  58836. buttonIndex?: number);
  58837. }
  58838. }
  58839. declare module BABYLON.GUI {
  58840. /**
  58841. * Class used as base class for controls
  58842. */
  58843. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  58844. /** Defines the control name */
  58845. name?: string | undefined;
  58846. /** @hidden */ host: GUI3DManager;
  58847. private _node;
  58848. private _downCount;
  58849. private _enterCount;
  58850. private _downPointerIds;
  58851. private _isVisible;
  58852. /** Gets or sets the control position in world space */
  58853. position: BABYLON.Vector3;
  58854. /** Gets or sets the control scaling in world space */
  58855. scaling: BABYLON.Vector3;
  58856. /** Callback used to start pointer enter animation */
  58857. pointerEnterAnimation: () => void;
  58858. /** Callback used to start pointer out animation */
  58859. pointerOutAnimation: () => void;
  58860. /** Callback used to start pointer down animation */
  58861. pointerDownAnimation: () => void;
  58862. /** Callback used to start pointer up animation */
  58863. pointerUpAnimation: () => void;
  58864. /**
  58865. * An event triggered when the pointer move over the control
  58866. */
  58867. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  58868. /**
  58869. * An event triggered when the pointer move out of the control
  58870. */
  58871. onPointerOutObservable: BABYLON.Observable<Control3D>;
  58872. /**
  58873. * An event triggered when the pointer taps the control
  58874. */
  58875. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  58876. /**
  58877. * An event triggered when pointer is up
  58878. */
  58879. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  58880. /**
  58881. * An event triggered when a control is clicked on (with a mouse)
  58882. */
  58883. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  58884. /**
  58885. * An event triggered when pointer enters the control
  58886. */
  58887. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  58888. /**
  58889. * Gets or sets the parent container
  58890. */
  58891. parent: BABYLON.Nullable<Container3D>;
  58892. private _behaviors;
  58893. /**
  58894. * Gets the list of attached behaviors
  58895. * @see http://doc.babylonjs.com/features/behaviour
  58896. */
  58897. readonly behaviors: BABYLON.Behavior<Control3D>[];
  58898. /**
  58899. * Attach a behavior to the control
  58900. * @see http://doc.babylonjs.com/features/behaviour
  58901. * @param behavior defines the behavior to attach
  58902. * @returns the current control
  58903. */
  58904. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  58905. /**
  58906. * Remove an attached behavior
  58907. * @see http://doc.babylonjs.com/features/behaviour
  58908. * @param behavior defines the behavior to attach
  58909. * @returns the current control
  58910. */
  58911. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  58912. /**
  58913. * Gets an attached behavior by name
  58914. * @param name defines the name of the behavior to look for
  58915. * @see http://doc.babylonjs.com/features/behaviour
  58916. * @returns null if behavior was not found else the requested behavior
  58917. */
  58918. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  58919. /** Gets or sets a boolean indicating if the control is visible */
  58920. isVisible: boolean;
  58921. /**
  58922. * Creates a new control
  58923. * @param name defines the control name
  58924. */
  58925. constructor(
  58926. /** Defines the control name */
  58927. name?: string | undefined);
  58928. /**
  58929. * Gets a string representing the class name
  58930. */
  58931. readonly typeName: string;
  58932. /**
  58933. * Get the current class name of the control.
  58934. * @returns current class name
  58935. */
  58936. getClassName(): string;
  58937. protected _getTypeName(): string;
  58938. /**
  58939. * Gets the transform node used by this control
  58940. */
  58941. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  58942. /**
  58943. * Gets the mesh used to render this control
  58944. */
  58945. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  58946. /**
  58947. * Link the control as child of the given node
  58948. * @param node defines the node to link to. Use null to unlink the control
  58949. * @returns the current control
  58950. */
  58951. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  58952. /** @hidden **/ prepareNode(scene: BABYLON.Scene): void;
  58953. /**
  58954. * Node creation.
  58955. * Can be overriden by children
  58956. * @param scene defines the scene where the node must be attached
  58957. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  58958. */
  58959. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  58960. /**
  58961. * Affect a material to the given mesh
  58962. * @param mesh defines the mesh which will represent the control
  58963. */
  58964. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  58965. /** @hidden */ onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  58966. /** @hidden */ onPointerEnter(target: Control3D): boolean;
  58967. /** @hidden */ onPointerOut(target: Control3D): void;
  58968. /** @hidden */ onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  58969. /** @hidden */ onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  58970. /** @hidden */
  58971. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  58972. /** @hidden */ processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  58973. /** @hidden */ disposeNode(): void;
  58974. /**
  58975. * Releases all associated resources
  58976. */
  58977. dispose(): void;
  58978. }
  58979. }
  58980. declare module BABYLON.GUI {
  58981. /**
  58982. * Class used as a root to all buttons
  58983. */
  58984. export class AbstractButton3D extends Control3D {
  58985. /**
  58986. * Creates a new button
  58987. * @param name defines the control name
  58988. */
  58989. constructor(name?: string);
  58990. protected _getTypeName(): string;
  58991. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  58992. }
  58993. }
  58994. declare module BABYLON.GUI {
  58995. /**
  58996. * Class used to create a button in 3D
  58997. */
  58998. export class Button3D extends AbstractButton3D {
  58999. /** @hidden */
  59000. protected _currentMaterial: BABYLON.Material;
  59001. private _facadeTexture;
  59002. private _content;
  59003. private _contentResolution;
  59004. private _contentScaleRatio;
  59005. /**
  59006. * Gets or sets the texture resolution used to render content (512 by default)
  59007. */
  59008. contentResolution: BABYLON.int;
  59009. /**
  59010. * Gets or sets the texture scale ratio used to render content (2 by default)
  59011. */
  59012. contentScaleRatio: number;
  59013. protected _disposeFacadeTexture(): void;
  59014. protected _resetContent(): void;
  59015. /**
  59016. * Creates a new button
  59017. * @param name defines the control name
  59018. */
  59019. constructor(name?: string);
  59020. /**
  59021. * Gets or sets the GUI 2D content used to display the button's facade
  59022. */
  59023. content: Control;
  59024. /**
  59025. * Apply the facade texture (created from the content property).
  59026. * This function can be overloaded by child classes
  59027. * @param facadeTexture defines the AdvancedDynamicTexture to use
  59028. */
  59029. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  59030. protected _getTypeName(): string;
  59031. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  59032. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  59033. /**
  59034. * Releases all associated resources
  59035. */
  59036. dispose(): void;
  59037. }
  59038. }
  59039. declare module BABYLON.GUI {
  59040. /**
  59041. * Abstract class used to create a container panel deployed on the surface of a volume
  59042. */
  59043. export abstract class VolumeBasedPanel extends Container3D {
  59044. private _columns;
  59045. private _rows;
  59046. private _rowThenColum;
  59047. private _orientation;
  59048. protected _cellWidth: number;
  59049. protected _cellHeight: number;
  59050. /**
  59051. * Gets or sets the distance between elements
  59052. */
  59053. margin: number;
  59054. /**
  59055. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  59056. * | Value | Type | Description |
  59057. * | ----- | ----------------------------------- | ----------- |
  59058. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  59059. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  59060. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  59061. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  59062. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  59063. */
  59064. orientation: number;
  59065. /**
  59066. * Gets or sets the number of columns requested (10 by default).
  59067. * The panel will automatically compute the number of rows based on number of child controls.
  59068. */
  59069. columns: BABYLON.int;
  59070. /**
  59071. * Gets or sets a the number of rows requested.
  59072. * The panel will automatically compute the number of columns based on number of child controls.
  59073. */
  59074. rows: BABYLON.int;
  59075. /**
  59076. * Creates new VolumeBasedPanel
  59077. */
  59078. constructor();
  59079. protected _arrangeChildren(): void;
  59080. /** Child classes must implement this function to provide correct control positioning */
  59081. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59082. /** Child classes can implement this function to provide additional processing */
  59083. protected _finalProcessing(): void;
  59084. }
  59085. }
  59086. declare module BABYLON.GUI {
  59087. /**
  59088. * Class used to create a container panel deployed on the surface of a cylinder
  59089. */
  59090. export class CylinderPanel extends VolumeBasedPanel {
  59091. private _radius;
  59092. /**
  59093. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  59094. */
  59095. radius: BABYLON.float;
  59096. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59097. private _cylindricalMapping;
  59098. }
  59099. }
  59100. declare module BABYLON.GUI {
  59101. /** @hidden */
  59102. export var fluentVertexShader: {
  59103. name: string;
  59104. shader: string;
  59105. };
  59106. }
  59107. declare module BABYLON.GUI {
  59108. /** @hidden */
  59109. export var fluentPixelShader: {
  59110. name: string;
  59111. shader: string;
  59112. };
  59113. }
  59114. declare module BABYLON.GUI {
  59115. /** @hidden */
  59116. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  59117. INNERGLOW: boolean;
  59118. BORDER: boolean;
  59119. HOVERLIGHT: boolean;
  59120. TEXTURE: boolean;
  59121. constructor();
  59122. }
  59123. /**
  59124. * Class used to render controls with fluent desgin
  59125. */
  59126. export class FluentMaterial extends BABYLON.PushMaterial {
  59127. /**
  59128. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  59129. */
  59130. innerGlowColorIntensity: number;
  59131. /**
  59132. * Gets or sets the inner glow color (white by default)
  59133. */
  59134. innerGlowColor: BABYLON.Color3;
  59135. /**
  59136. * Gets or sets alpha value (default is 1.0)
  59137. */
  59138. alpha: number;
  59139. /**
  59140. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  59141. */
  59142. albedoColor: BABYLON.Color3;
  59143. /**
  59144. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  59145. */
  59146. renderBorders: boolean;
  59147. /**
  59148. * Gets or sets border width (default is 0.5)
  59149. */
  59150. borderWidth: number;
  59151. /**
  59152. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  59153. */
  59154. edgeSmoothingValue: number;
  59155. /**
  59156. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  59157. */
  59158. borderMinValue: number;
  59159. /**
  59160. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  59161. */
  59162. renderHoverLight: boolean;
  59163. /**
  59164. * Gets or sets the radius used to render the hover light (default is 1.0)
  59165. */
  59166. hoverRadius: number;
  59167. /**
  59168. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  59169. */
  59170. hoverColor: BABYLON.Color4;
  59171. /**
  59172. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  59173. */
  59174. hoverPosition: BABYLON.Vector3;
  59175. private _albedoTexture;
  59176. /** Gets or sets the texture to use for albedo color */
  59177. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  59178. /**
  59179. * Creates a new Fluent material
  59180. * @param name defines the name of the material
  59181. * @param scene defines the hosting scene
  59182. */
  59183. constructor(name: string, scene: BABYLON.Scene);
  59184. needAlphaBlending(): boolean;
  59185. needAlphaTesting(): boolean;
  59186. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  59187. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  59188. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  59189. getActiveTextures(): BABYLON.BaseTexture[];
  59190. hasTexture(texture: BABYLON.BaseTexture): boolean;
  59191. dispose(forceDisposeEffect?: boolean): void;
  59192. clone(name: string): FluentMaterial;
  59193. serialize(): any;
  59194. getClassName(): string;
  59195. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  59196. }
  59197. }
  59198. declare module BABYLON.GUI {
  59199. /**
  59200. * Class used to create a holographic button in 3D
  59201. */
  59202. export class HolographicButton extends Button3D {
  59203. private _backPlate;
  59204. private _textPlate;
  59205. private _frontPlate;
  59206. private _text;
  59207. private _imageUrl;
  59208. private _shareMaterials;
  59209. private _frontMaterial;
  59210. private _backMaterial;
  59211. private _plateMaterial;
  59212. private _pickedPointObserver;
  59213. private _tooltipFade;
  59214. private _tooltipTextBlock;
  59215. private _tooltipTexture;
  59216. private _tooltipMesh;
  59217. private _tooltipHoverObserver;
  59218. private _tooltipOutObserver;
  59219. private _disposeTooltip;
  59220. /**
  59221. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  59222. */
  59223. tooltipText: BABYLON.Nullable<string>;
  59224. /**
  59225. * Gets or sets text for the button
  59226. */
  59227. text: string;
  59228. /**
  59229. * Gets or sets the image url for the button
  59230. */
  59231. imageUrl: string;
  59232. /**
  59233. * Gets the back material used by this button
  59234. */
  59235. readonly backMaterial: FluentMaterial;
  59236. /**
  59237. * Gets the front material used by this button
  59238. */
  59239. readonly frontMaterial: FluentMaterial;
  59240. /**
  59241. * Gets the plate material used by this button
  59242. */
  59243. readonly plateMaterial: BABYLON.StandardMaterial;
  59244. /**
  59245. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  59246. */
  59247. readonly shareMaterials: boolean;
  59248. /**
  59249. * Creates a new button
  59250. * @param name defines the control name
  59251. */
  59252. constructor(name?: string, shareMaterials?: boolean);
  59253. protected _getTypeName(): string;
  59254. private _rebuildContent;
  59255. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  59256. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  59257. private _createBackMaterial;
  59258. private _createFrontMaterial;
  59259. private _createPlateMaterial;
  59260. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  59261. /**
  59262. * Releases all associated resources
  59263. */
  59264. dispose(): void;
  59265. }
  59266. }
  59267. declare module BABYLON.GUI {
  59268. /**
  59269. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  59270. */
  59271. export class MeshButton3D extends Button3D {
  59272. /** @hidden */
  59273. protected _currentMesh: BABYLON.Mesh;
  59274. /**
  59275. * Creates a new 3D button based on a mesh
  59276. * @param mesh mesh to become a 3D button
  59277. * @param name defines the control name
  59278. */
  59279. constructor(mesh: BABYLON.Mesh, name?: string);
  59280. protected _getTypeName(): string;
  59281. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  59282. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  59283. }
  59284. }
  59285. declare module BABYLON.GUI {
  59286. /**
  59287. * Class used to create a container panel deployed on the surface of a plane
  59288. */
  59289. export class PlanePanel extends VolumeBasedPanel {
  59290. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59291. }
  59292. }
  59293. declare module BABYLON.GUI {
  59294. /**
  59295. * Class used to create a container panel where items get randomized planar mapping
  59296. */
  59297. export class ScatterPanel extends VolumeBasedPanel {
  59298. private _iteration;
  59299. /**
  59300. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  59301. */
  59302. iteration: BABYLON.float;
  59303. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59304. private _scatterMapping;
  59305. protected _finalProcessing(): void;
  59306. }
  59307. }
  59308. declare module BABYLON.GUI {
  59309. /**
  59310. * Class used to create a container panel deployed on the surface of a sphere
  59311. */
  59312. export class SpherePanel extends VolumeBasedPanel {
  59313. private _radius;
  59314. /**
  59315. * Gets or sets the radius of the sphere where to project controls (5 by default)
  59316. */
  59317. radius: BABYLON.float;
  59318. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59319. private _sphericalMapping;
  59320. }
  59321. }
  59322. declare module BABYLON.GUI {
  59323. /**
  59324. * Class used to create a stack panel in 3D on XY plane
  59325. */
  59326. export class StackPanel3D extends Container3D {
  59327. private _isVertical;
  59328. /**
  59329. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  59330. */
  59331. isVertical: boolean;
  59332. /**
  59333. * Gets or sets the distance between elements
  59334. */
  59335. margin: number;
  59336. /**
  59337. * Creates new StackPanel
  59338. * @param isVertical
  59339. */
  59340. constructor(isVertical?: boolean);
  59341. protected _arrangeChildren(): void;
  59342. }
  59343. }
  59344. declare module BABYLON {
  59345. /**
  59346. * Mode that determines the coordinate system to use.
  59347. */
  59348. export enum GLTFLoaderCoordinateSystemMode {
  59349. /**
  59350. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  59351. */
  59352. AUTO = 0,
  59353. /**
  59354. * Sets the useRightHandedSystem flag on the scene.
  59355. */
  59356. FORCE_RIGHT_HANDED = 1
  59357. }
  59358. /**
  59359. * Mode that determines what animations will start.
  59360. */
  59361. export enum GLTFLoaderAnimationStartMode {
  59362. /**
  59363. * No animation will start.
  59364. */
  59365. NONE = 0,
  59366. /**
  59367. * The first animation will start.
  59368. */
  59369. FIRST = 1,
  59370. /**
  59371. * All animations will start.
  59372. */
  59373. ALL = 2
  59374. }
  59375. /**
  59376. * Interface that contains the data for the glTF asset.
  59377. */
  59378. export interface IGLTFLoaderData {
  59379. /**
  59380. * Object that represents the glTF JSON.
  59381. */
  59382. json: Object;
  59383. /**
  59384. * The BIN chunk of a binary glTF.
  59385. */
  59386. bin: Nullable<ArrayBufferView>;
  59387. }
  59388. /**
  59389. * Interface for extending the loader.
  59390. */
  59391. export interface IGLTFLoaderExtension {
  59392. /**
  59393. * The name of this extension.
  59394. */
  59395. readonly name: string;
  59396. /**
  59397. * Defines whether this extension is enabled.
  59398. */
  59399. enabled: boolean;
  59400. }
  59401. /**
  59402. * Loader state.
  59403. */
  59404. export enum GLTFLoaderState {
  59405. /**
  59406. * The asset is loading.
  59407. */
  59408. LOADING = 0,
  59409. /**
  59410. * The asset is ready for rendering.
  59411. */
  59412. READY = 1,
  59413. /**
  59414. * The asset is completely loaded.
  59415. */
  59416. COMPLETE = 2
  59417. }
  59418. /** @hidden */
  59419. export interface IGLTFLoader extends IDisposable {
  59420. readonly state: Nullable<GLTFLoaderState>;
  59421. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  59422. meshes: AbstractMesh[];
  59423. particleSystems: IParticleSystem[];
  59424. skeletons: Skeleton[];
  59425. animationGroups: AnimationGroup[];
  59426. }>;
  59427. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  59428. }
  59429. /**
  59430. * File loader for loading glTF files into a scene.
  59431. */
  59432. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  59433. /** @hidden */ private static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  59434. /** @hidden */ private static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  59435. /**
  59436. * Raised when the asset has been parsed
  59437. */
  59438. onParsedObservable: Observable<IGLTFLoaderData>;
  59439. private _onParsedObserver;
  59440. /**
  59441. * Raised when the asset has been parsed
  59442. */
  59443. onParsed: (loaderData: IGLTFLoaderData) => void;
  59444. /**
  59445. * 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.
  59446. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  59447. * Defaults to true.
  59448. * @hidden
  59449. */
  59450. static IncrementalLoading: boolean;
  59451. /**
  59452. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  59453. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  59454. * @hidden
  59455. */
  59456. static HomogeneousCoordinates: boolean;
  59457. /**
  59458. * The coordinate system mode. Defaults to AUTO.
  59459. */
  59460. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  59461. /**
  59462. * The animation start mode. Defaults to FIRST.
  59463. */
  59464. animationStartMode: GLTFLoaderAnimationStartMode;
  59465. /**
  59466. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  59467. */
  59468. compileMaterials: boolean;
  59469. /**
  59470. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  59471. */
  59472. useClipPlane: boolean;
  59473. /**
  59474. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  59475. */
  59476. compileShadowGenerators: boolean;
  59477. /**
  59478. * Defines if the Alpha blended materials are only applied as coverage.
  59479. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  59480. * If true, no extra effects are applied to transparent pixels.
  59481. */
  59482. transparencyAsCoverage: boolean;
  59483. /**
  59484. * Function called before loading a url referenced by the asset.
  59485. */
  59486. preprocessUrlAsync: (url: string) => Promise<string>;
  59487. /**
  59488. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  59489. */
  59490. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  59491. private _onMeshLoadedObserver;
  59492. /**
  59493. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  59494. */
  59495. onMeshLoaded: (mesh: AbstractMesh) => void;
  59496. /**
  59497. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  59498. */
  59499. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  59500. private _onTextureLoadedObserver;
  59501. /**
  59502. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  59503. */
  59504. onTextureLoaded: (texture: BaseTexture) => void;
  59505. /**
  59506. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  59507. */
  59508. readonly onMaterialLoadedObservable: Observable<Material>;
  59509. private _onMaterialLoadedObserver;
  59510. /**
  59511. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  59512. */
  59513. onMaterialLoaded: (material: Material) => void;
  59514. /**
  59515. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  59516. */
  59517. readonly onCameraLoadedObservable: Observable<Camera>;
  59518. private _onCameraLoadedObserver;
  59519. /**
  59520. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  59521. */
  59522. onCameraLoaded: (camera: Camera) => void;
  59523. /**
  59524. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  59525. * For assets with LODs, raised when all of the LODs are complete.
  59526. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  59527. */
  59528. readonly onCompleteObservable: Observable<void>;
  59529. private _onCompleteObserver;
  59530. /**
  59531. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  59532. * For assets with LODs, raised when all of the LODs are complete.
  59533. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  59534. */
  59535. onComplete: () => void;
  59536. /**
  59537. * Observable raised when an error occurs.
  59538. */
  59539. readonly onErrorObservable: Observable<any>;
  59540. private _onErrorObserver;
  59541. /**
  59542. * Callback raised when an error occurs.
  59543. */
  59544. onError: (reason: any) => void;
  59545. /**
  59546. * Observable raised after the loader is disposed.
  59547. */
  59548. readonly onDisposeObservable: Observable<void>;
  59549. private _onDisposeObserver;
  59550. /**
  59551. * Callback raised after the loader is disposed.
  59552. */
  59553. onDispose: () => void;
  59554. /**
  59555. * Observable raised after a loader extension is created.
  59556. * Set additional options for a loader extension in this event.
  59557. */
  59558. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  59559. private _onExtensionLoadedObserver;
  59560. /**
  59561. * Callback raised after a loader extension is created.
  59562. */
  59563. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  59564. /**
  59565. * Defines if the loader logging is enabled.
  59566. */
  59567. loggingEnabled: boolean;
  59568. /**
  59569. * Defines if the loader should capture performance counters.
  59570. */
  59571. capturePerformanceCounters: boolean;
  59572. /**
  59573. * Defines if the loader should validate the asset.
  59574. */
  59575. validate: boolean;
  59576. /**
  59577. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  59578. */
  59579. readonly onValidatedObservable: Observable<IGLTFValidationResults>;
  59580. private _onValidatedObserver;
  59581. /**
  59582. * Callback raised after a loader extension is created.
  59583. */
  59584. onValidated: (results: IGLTFValidationResults) => void;
  59585. private _loader;
  59586. /**
  59587. * Name of the loader ("gltf")
  59588. */
  59589. name: string;
  59590. /**
  59591. * Supported file extensions of the loader (.gltf, .glb)
  59592. */
  59593. extensions: ISceneLoaderPluginExtensions;
  59594. /**
  59595. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  59596. */
  59597. dispose(): void;
  59598. /** @hidden */ clear(): void;
  59599. /**
  59600. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  59601. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  59602. * @param scene the scene the meshes should be added to
  59603. * @param data the glTF data to load
  59604. * @param rootUrl root url to load from
  59605. * @param onProgress event that fires when loading progress has occured
  59606. * @param fileName Defines the name of the file to load
  59607. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  59608. */
  59609. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  59610. meshes: AbstractMesh[];
  59611. particleSystems: IParticleSystem[];
  59612. skeletons: Skeleton[];
  59613. animationGroups: AnimationGroup[];
  59614. }>;
  59615. /**
  59616. * Imports all objects from the loaded glTF data and adds them to the scene
  59617. * @param scene the scene the objects should be added to
  59618. * @param data the glTF data to load
  59619. * @param rootUrl root url to load from
  59620. * @param onProgress event that fires when loading progress has occured
  59621. * @param fileName Defines the name of the file to load
  59622. * @returns a promise which completes when objects have been loaded to the scene
  59623. */
  59624. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  59625. /**
  59626. * Load into an asset container.
  59627. * @param scene The scene to load into
  59628. * @param data The data to import
  59629. * @param rootUrl The root url for scene and resources
  59630. * @param onProgress The callback when the load progresses
  59631. * @param fileName Defines the name of the file to load
  59632. * @returns The loaded asset container
  59633. */
  59634. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  59635. /**
  59636. * If the data string can be loaded directly.
  59637. * @param data string contianing the file data
  59638. * @returns if the data can be loaded directly
  59639. */
  59640. canDirectLoad(data: string): boolean;
  59641. /**
  59642. * Rewrites a url by combining a root url and response url.
  59643. */
  59644. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  59645. /**
  59646. * Instantiates a glTF file loader plugin.
  59647. * @returns the created plugin
  59648. */
  59649. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  59650. /**
  59651. * The loader state or null if the loader is not active.
  59652. */
  59653. readonly loaderState: Nullable<GLTFLoaderState>;
  59654. /**
  59655. * Returns a promise that resolves when the asset is completely loaded.
  59656. * @returns a promise that resolves when the asset is completely loaded.
  59657. */
  59658. whenCompleteAsync(): Promise<void>;
  59659. private _parseAsync;
  59660. private _validateAsync;
  59661. private _getLoader;
  59662. private _unpackBinary;
  59663. private _unpackBinaryV1;
  59664. private _unpackBinaryV2;
  59665. private static _parseVersion;
  59666. private static _compareVersion;
  59667. private static _decodeBufferToText;
  59668. private static readonly _logSpaces;
  59669. private _logIndentLevel;
  59670. private _loggingEnabled;
  59671. /** @hidden */ log: (message: string) => void;
  59672. /** @hidden */ logOpen(message: string): void;
  59673. /** @hidden */ logClose(): void;
  59674. private _logEnabled;
  59675. private _logDisabled;
  59676. private _capturePerformanceCounters;
  59677. /** @hidden */ startPerformanceCounter: (counterName: string) => void;
  59678. /** @hidden */ endPerformanceCounter: (counterName: string) => void;
  59679. private _startPerformanceCounterEnabled;
  59680. private _startPerformanceCounterDisabled;
  59681. private _endPerformanceCounterEnabled;
  59682. private _endPerformanceCounterDisabled;
  59683. }
  59684. }
  59685. declare module BABYLON.GLTF1 {
  59686. /**
  59687. * Enums
  59688. * @hidden
  59689. */
  59690. export enum EComponentType {
  59691. BYTE = 5120,
  59692. UNSIGNED_BYTE = 5121,
  59693. SHORT = 5122,
  59694. UNSIGNED_SHORT = 5123,
  59695. FLOAT = 5126
  59696. }
  59697. /** @hidden */
  59698. export enum EShaderType {
  59699. FRAGMENT = 35632,
  59700. VERTEX = 35633
  59701. }
  59702. /** @hidden */
  59703. export enum EParameterType {
  59704. BYTE = 5120,
  59705. UNSIGNED_BYTE = 5121,
  59706. SHORT = 5122,
  59707. UNSIGNED_SHORT = 5123,
  59708. INT = 5124,
  59709. UNSIGNED_INT = 5125,
  59710. FLOAT = 5126,
  59711. FLOAT_VEC2 = 35664,
  59712. FLOAT_VEC3 = 35665,
  59713. FLOAT_VEC4 = 35666,
  59714. INT_VEC2 = 35667,
  59715. INT_VEC3 = 35668,
  59716. INT_VEC4 = 35669,
  59717. BOOL = 35670,
  59718. BOOL_VEC2 = 35671,
  59719. BOOL_VEC3 = 35672,
  59720. BOOL_VEC4 = 35673,
  59721. FLOAT_MAT2 = 35674,
  59722. FLOAT_MAT3 = 35675,
  59723. FLOAT_MAT4 = 35676,
  59724. SAMPLER_2D = 35678
  59725. }
  59726. /** @hidden */
  59727. export enum ETextureWrapMode {
  59728. CLAMP_TO_EDGE = 33071,
  59729. MIRRORED_REPEAT = 33648,
  59730. REPEAT = 10497
  59731. }
  59732. /** @hidden */
  59733. export enum ETextureFilterType {
  59734. NEAREST = 9728,
  59735. LINEAR = 9728,
  59736. NEAREST_MIPMAP_NEAREST = 9984,
  59737. LINEAR_MIPMAP_NEAREST = 9985,
  59738. NEAREST_MIPMAP_LINEAR = 9986,
  59739. LINEAR_MIPMAP_LINEAR = 9987
  59740. }
  59741. /** @hidden */
  59742. export enum ETextureFormat {
  59743. ALPHA = 6406,
  59744. RGB = 6407,
  59745. RGBA = 6408,
  59746. LUMINANCE = 6409,
  59747. LUMINANCE_ALPHA = 6410
  59748. }
  59749. /** @hidden */
  59750. export enum ECullingType {
  59751. FRONT = 1028,
  59752. BACK = 1029,
  59753. FRONT_AND_BACK = 1032
  59754. }
  59755. /** @hidden */
  59756. export enum EBlendingFunction {
  59757. ZERO = 0,
  59758. ONE = 1,
  59759. SRC_COLOR = 768,
  59760. ONE_MINUS_SRC_COLOR = 769,
  59761. DST_COLOR = 774,
  59762. ONE_MINUS_DST_COLOR = 775,
  59763. SRC_ALPHA = 770,
  59764. ONE_MINUS_SRC_ALPHA = 771,
  59765. DST_ALPHA = 772,
  59766. ONE_MINUS_DST_ALPHA = 773,
  59767. CONSTANT_COLOR = 32769,
  59768. ONE_MINUS_CONSTANT_COLOR = 32770,
  59769. CONSTANT_ALPHA = 32771,
  59770. ONE_MINUS_CONSTANT_ALPHA = 32772,
  59771. SRC_ALPHA_SATURATE = 776
  59772. }
  59773. /** @hidden */
  59774. export interface IGLTFProperty {
  59775. extensions?: {
  59776. [key: string]: any;
  59777. };
  59778. extras?: Object;
  59779. }
  59780. /** @hidden */
  59781. export interface IGLTFChildRootProperty extends IGLTFProperty {
  59782. name?: string;
  59783. }
  59784. /** @hidden */
  59785. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  59786. bufferView: string;
  59787. byteOffset: number;
  59788. byteStride: number;
  59789. count: number;
  59790. type: string;
  59791. componentType: EComponentType;
  59792. max?: number[];
  59793. min?: number[];
  59794. name?: string;
  59795. }
  59796. /** @hidden */
  59797. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  59798. buffer: string;
  59799. byteOffset: number;
  59800. byteLength: number;
  59801. byteStride: number;
  59802. target?: number;
  59803. }
  59804. /** @hidden */
  59805. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  59806. uri: string;
  59807. byteLength?: number;
  59808. type?: string;
  59809. }
  59810. /** @hidden */
  59811. export interface IGLTFShader extends IGLTFChildRootProperty {
  59812. uri: string;
  59813. type: EShaderType;
  59814. }
  59815. /** @hidden */
  59816. export interface IGLTFProgram extends IGLTFChildRootProperty {
  59817. attributes: string[];
  59818. fragmentShader: string;
  59819. vertexShader: string;
  59820. }
  59821. /** @hidden */
  59822. export interface IGLTFTechniqueParameter {
  59823. type: number;
  59824. count?: number;
  59825. semantic?: string;
  59826. node?: string;
  59827. value?: number | boolean | string | Array<any>;
  59828. source?: string;
  59829. babylonValue?: any;
  59830. }
  59831. /** @hidden */
  59832. export interface IGLTFTechniqueCommonProfile {
  59833. lightingModel: string;
  59834. texcoordBindings: Object;
  59835. parameters?: Array<any>;
  59836. }
  59837. /** @hidden */
  59838. export interface IGLTFTechniqueStatesFunctions {
  59839. blendColor?: number[];
  59840. blendEquationSeparate?: number[];
  59841. blendFuncSeparate?: number[];
  59842. colorMask: boolean[];
  59843. cullFace: number[];
  59844. }
  59845. /** @hidden */
  59846. export interface IGLTFTechniqueStates {
  59847. enable: number[];
  59848. functions: IGLTFTechniqueStatesFunctions;
  59849. }
  59850. /** @hidden */
  59851. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  59852. parameters: {
  59853. [key: string]: IGLTFTechniqueParameter;
  59854. };
  59855. program: string;
  59856. attributes: {
  59857. [key: string]: string;
  59858. };
  59859. uniforms: {
  59860. [key: string]: string;
  59861. };
  59862. states: IGLTFTechniqueStates;
  59863. }
  59864. /** @hidden */
  59865. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  59866. technique?: string;
  59867. values: string[];
  59868. }
  59869. /** @hidden */
  59870. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  59871. attributes: {
  59872. [key: string]: string;
  59873. };
  59874. indices: string;
  59875. material: string;
  59876. mode?: number;
  59877. }
  59878. /** @hidden */
  59879. export interface IGLTFMesh extends IGLTFChildRootProperty {
  59880. primitives: IGLTFMeshPrimitive[];
  59881. }
  59882. /** @hidden */
  59883. export interface IGLTFImage extends IGLTFChildRootProperty {
  59884. uri: string;
  59885. }
  59886. /** @hidden */
  59887. export interface IGLTFSampler extends IGLTFChildRootProperty {
  59888. magFilter?: number;
  59889. minFilter?: number;
  59890. wrapS?: number;
  59891. wrapT?: number;
  59892. }
  59893. /** @hidden */
  59894. export interface IGLTFTexture extends IGLTFChildRootProperty {
  59895. sampler: string;
  59896. source: string;
  59897. format?: ETextureFormat;
  59898. internalFormat?: ETextureFormat;
  59899. target?: number;
  59900. type?: number;
  59901. babylonTexture?: Texture;
  59902. }
  59903. /** @hidden */
  59904. export interface IGLTFAmbienLight {
  59905. color?: number[];
  59906. }
  59907. /** @hidden */
  59908. export interface IGLTFDirectionalLight {
  59909. color?: number[];
  59910. }
  59911. /** @hidden */
  59912. export interface IGLTFPointLight {
  59913. color?: number[];
  59914. constantAttenuation?: number;
  59915. linearAttenuation?: number;
  59916. quadraticAttenuation?: number;
  59917. }
  59918. /** @hidden */
  59919. export interface IGLTFSpotLight {
  59920. color?: number[];
  59921. constantAttenuation?: number;
  59922. fallOfAngle?: number;
  59923. fallOffExponent?: number;
  59924. linearAttenuation?: number;
  59925. quadraticAttenuation?: number;
  59926. }
  59927. /** @hidden */
  59928. export interface IGLTFLight extends IGLTFChildRootProperty {
  59929. type: string;
  59930. }
  59931. /** @hidden */
  59932. export interface IGLTFCameraOrthographic {
  59933. xmag: number;
  59934. ymag: number;
  59935. zfar: number;
  59936. znear: number;
  59937. }
  59938. /** @hidden */
  59939. export interface IGLTFCameraPerspective {
  59940. aspectRatio: number;
  59941. yfov: number;
  59942. zfar: number;
  59943. znear: number;
  59944. }
  59945. /** @hidden */
  59946. export interface IGLTFCamera extends IGLTFChildRootProperty {
  59947. type: string;
  59948. }
  59949. /** @hidden */
  59950. export interface IGLTFAnimationChannelTarget {
  59951. id: string;
  59952. path: string;
  59953. }
  59954. /** @hidden */
  59955. export interface IGLTFAnimationChannel {
  59956. sampler: string;
  59957. target: IGLTFAnimationChannelTarget;
  59958. }
  59959. /** @hidden */
  59960. export interface IGLTFAnimationSampler {
  59961. input: string;
  59962. output: string;
  59963. interpolation?: string;
  59964. }
  59965. /** @hidden */
  59966. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  59967. channels?: IGLTFAnimationChannel[];
  59968. parameters?: {
  59969. [key: string]: string;
  59970. };
  59971. samplers?: {
  59972. [key: string]: IGLTFAnimationSampler;
  59973. };
  59974. }
  59975. /** @hidden */
  59976. export interface IGLTFNodeInstanceSkin {
  59977. skeletons: string[];
  59978. skin: string;
  59979. meshes: string[];
  59980. }
  59981. /** @hidden */
  59982. export interface IGLTFSkins extends IGLTFChildRootProperty {
  59983. bindShapeMatrix: number[];
  59984. inverseBindMatrices: string;
  59985. jointNames: string[];
  59986. babylonSkeleton?: Skeleton;
  59987. }
  59988. /** @hidden */
  59989. export interface IGLTFNode extends IGLTFChildRootProperty {
  59990. camera?: string;
  59991. children: string[];
  59992. skin?: string;
  59993. jointName?: string;
  59994. light?: string;
  59995. matrix: number[];
  59996. mesh?: string;
  59997. meshes?: string[];
  59998. rotation?: number[];
  59999. scale?: number[];
  60000. translation?: number[];
  60001. babylonNode?: Node;
  60002. }
  60003. /** @hidden */
  60004. export interface IGLTFScene extends IGLTFChildRootProperty {
  60005. nodes: string[];
  60006. }
  60007. /** @hidden */
  60008. export interface IGLTFRuntime {
  60009. extensions: {
  60010. [key: string]: any;
  60011. };
  60012. accessors: {
  60013. [key: string]: IGLTFAccessor;
  60014. };
  60015. buffers: {
  60016. [key: string]: IGLTFBuffer;
  60017. };
  60018. bufferViews: {
  60019. [key: string]: IGLTFBufferView;
  60020. };
  60021. meshes: {
  60022. [key: string]: IGLTFMesh;
  60023. };
  60024. lights: {
  60025. [key: string]: IGLTFLight;
  60026. };
  60027. cameras: {
  60028. [key: string]: IGLTFCamera;
  60029. };
  60030. nodes: {
  60031. [key: string]: IGLTFNode;
  60032. };
  60033. images: {
  60034. [key: string]: IGLTFImage;
  60035. };
  60036. textures: {
  60037. [key: string]: IGLTFTexture;
  60038. };
  60039. shaders: {
  60040. [key: string]: IGLTFShader;
  60041. };
  60042. programs: {
  60043. [key: string]: IGLTFProgram;
  60044. };
  60045. samplers: {
  60046. [key: string]: IGLTFSampler;
  60047. };
  60048. techniques: {
  60049. [key: string]: IGLTFTechnique;
  60050. };
  60051. materials: {
  60052. [key: string]: IGLTFMaterial;
  60053. };
  60054. animations: {
  60055. [key: string]: IGLTFAnimation;
  60056. };
  60057. skins: {
  60058. [key: string]: IGLTFSkins;
  60059. };
  60060. currentScene?: Object;
  60061. scenes: {
  60062. [key: string]: IGLTFScene;
  60063. };
  60064. extensionsUsed: string[];
  60065. extensionsRequired?: string[];
  60066. buffersCount: number;
  60067. shaderscount: number;
  60068. scene: Scene;
  60069. rootUrl: string;
  60070. loadedBufferCount: number;
  60071. loadedBufferViews: {
  60072. [name: string]: ArrayBufferView;
  60073. };
  60074. loadedShaderCount: number;
  60075. importOnlyMeshes: boolean;
  60076. importMeshesNames?: string[];
  60077. dummyNodes: Node[];
  60078. }
  60079. /** @hidden */
  60080. export interface INodeToRoot {
  60081. bone: Bone;
  60082. node: IGLTFNode;
  60083. id: string;
  60084. }
  60085. /** @hidden */
  60086. export interface IJointNode {
  60087. node: IGLTFNode;
  60088. id: string;
  60089. }
  60090. }
  60091. declare module BABYLON.GLTF1 {
  60092. /**
  60093. * Utils functions for GLTF
  60094. * @hidden
  60095. */
  60096. export class GLTFUtils {
  60097. /**
  60098. * Sets the given "parameter" matrix
  60099. * @param scene: the Scene object
  60100. * @param source: the source node where to pick the matrix
  60101. * @param parameter: the GLTF technique parameter
  60102. * @param uniformName: the name of the shader's uniform
  60103. * @param shaderMaterial: the shader material
  60104. */
  60105. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  60106. /**
  60107. * Sets the given "parameter" matrix
  60108. * @param shaderMaterial: the shader material
  60109. * @param uniform: the name of the shader's uniform
  60110. * @param value: the value of the uniform
  60111. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  60112. */
  60113. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  60114. /**
  60115. * Returns the wrap mode of the texture
  60116. * @param mode: the mode value
  60117. */
  60118. static GetWrapMode(mode: number): number;
  60119. /**
  60120. * Returns the byte stride giving an accessor
  60121. * @param accessor: the GLTF accessor objet
  60122. */
  60123. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  60124. /**
  60125. * Returns the texture filter mode giving a mode value
  60126. * @param mode: the filter mode value
  60127. */
  60128. static GetTextureFilterMode(mode: number): ETextureFilterType;
  60129. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  60130. /**
  60131. * Returns a buffer from its accessor
  60132. * @param gltfRuntime: the GLTF runtime
  60133. * @param accessor: the GLTF accessor
  60134. */
  60135. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  60136. /**
  60137. * Decodes a buffer view into a string
  60138. * @param view: the buffer view
  60139. */
  60140. static DecodeBufferToText(view: ArrayBufferView): string;
  60141. /**
  60142. * Returns the default material of gltf. Related to
  60143. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  60144. * @param scene: the Babylon.js scene
  60145. */
  60146. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  60147. private static _DefaultMaterial;
  60148. }
  60149. }
  60150. declare module BABYLON.GLTF1 {
  60151. /**
  60152. * Implementation of the base glTF spec
  60153. * @hidden
  60154. */
  60155. export class GLTFLoaderBase {
  60156. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  60157. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  60158. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  60159. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  60160. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  60161. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  60162. }
  60163. /**
  60164. * glTF V1 Loader
  60165. * @hidden
  60166. */
  60167. export class GLTFLoader implements IGLTFLoader {
  60168. static Extensions: {
  60169. [name: string]: GLTFLoaderExtension;
  60170. };
  60171. static RegisterExtension(extension: GLTFLoaderExtension): void;
  60172. state: Nullable<GLTFLoaderState>;
  60173. dispose(): void;
  60174. private _importMeshAsync;
  60175. /**
  60176. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  60177. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  60178. * @param scene the scene the meshes should be added to
  60179. * @param data gltf data containing information of the meshes in a loaded file
  60180. * @param rootUrl root url to load from
  60181. * @param onProgress event that fires when loading progress has occured
  60182. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  60183. */
  60184. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  60185. meshes: AbstractMesh[];
  60186. particleSystems: IParticleSystem[];
  60187. skeletons: Skeleton[];
  60188. animationGroups: AnimationGroup[];
  60189. }>;
  60190. private _loadAsync;
  60191. /**
  60192. * Imports all objects from a loaded gltf file and adds them to the scene
  60193. * @param scene the scene the objects should be added to
  60194. * @param data gltf data containing information of the meshes in a loaded file
  60195. * @param rootUrl root url to load from
  60196. * @param onProgress event that fires when loading progress has occured
  60197. * @returns a promise which completes when objects have been loaded to the scene
  60198. */
  60199. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  60200. private _loadShadersAsync;
  60201. private _loadBuffersAsync;
  60202. private _createNodes;
  60203. }
  60204. /** @hidden */
  60205. export abstract class GLTFLoaderExtension {
  60206. private _name;
  60207. constructor(name: string);
  60208. readonly name: string;
  60209. /**
  60210. * Defines an override for loading the runtime
  60211. * Return true to stop further extensions from loading the runtime
  60212. */
  60213. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  60214. /**
  60215. * Defines an onverride for creating gltf runtime
  60216. * Return true to stop further extensions from creating the runtime
  60217. */
  60218. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  60219. /**
  60220. * Defines an override for loading buffers
  60221. * Return true to stop further extensions from loading this buffer
  60222. */
  60223. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  60224. /**
  60225. * Defines an override for loading texture buffers
  60226. * Return true to stop further extensions from loading this texture data
  60227. */
  60228. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  60229. /**
  60230. * Defines an override for creating textures
  60231. * Return true to stop further extensions from loading this texture
  60232. */
  60233. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  60234. /**
  60235. * Defines an override for loading shader strings
  60236. * Return true to stop further extensions from loading this shader data
  60237. */
  60238. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  60239. /**
  60240. * Defines an override for loading materials
  60241. * Return true to stop further extensions from loading this material
  60242. */
  60243. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  60244. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  60245. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  60246. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  60247. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  60248. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  60249. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  60250. private static LoadTextureBufferAsync;
  60251. private static CreateTextureAsync;
  60252. private static ApplyExtensions;
  60253. }
  60254. }
  60255. declare module BABYLON.GLTF1 {
  60256. /** @hidden */
  60257. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  60258. private _bin;
  60259. constructor();
  60260. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  60261. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  60262. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  60263. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  60264. }
  60265. }
  60266. declare module BABYLON.GLTF1 {
  60267. /** @hidden */
  60268. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  60269. constructor();
  60270. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  60271. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  60272. private _loadTexture;
  60273. }
  60274. }
  60275. declare module BABYLON.GLTF2.Loader {
  60276. /**
  60277. * Loader interface with an index field.
  60278. */
  60279. export interface IArrayItem {
  60280. /**
  60281. * The index of this item in the array.
  60282. */
  60283. index: number;
  60284. }
  60285. /**
  60286. * Loader interface with additional members.
  60287. */
  60288. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  60289. /** @hidden */ data?: Promise<ArrayBufferView>;
  60290. /** @hidden */ babylonVertexBuffer?: Promise<VertexBuffer>;
  60291. }
  60292. /**
  60293. * Loader interface with additional members.
  60294. */
  60295. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  60296. }
  60297. /** @hidden */
  60298. export interface _IAnimationSamplerData {
  60299. input: Float32Array;
  60300. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  60301. output: Float32Array;
  60302. }
  60303. /**
  60304. * Loader interface with additional members.
  60305. */
  60306. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  60307. /** @hidden */ data?: Promise<_IAnimationSamplerData>;
  60308. }
  60309. /**
  60310. * Loader interface with additional members.
  60311. */
  60312. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  60313. channels: IAnimationChannel[];
  60314. samplers: IAnimationSampler[];
  60315. /** @hidden */ babylonAnimationGroup?: AnimationGroup;
  60316. }
  60317. /**
  60318. * Loader interface with additional members.
  60319. */
  60320. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  60321. /** @hidden */ data?: Promise<ArrayBufferView>;
  60322. }
  60323. /**
  60324. * Loader interface with additional members.
  60325. */
  60326. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  60327. /** @hidden */ data?: Promise<ArrayBufferView>;
  60328. /** @hidden */ babylonBuffer?: Promise<Buffer>;
  60329. }
  60330. /**
  60331. * Loader interface with additional members.
  60332. */
  60333. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  60334. }
  60335. /**
  60336. * Loader interface with additional members.
  60337. */
  60338. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  60339. /** @hidden */ data?: Promise<ArrayBufferView>;
  60340. }
  60341. /**
  60342. * Loader interface with additional members.
  60343. */
  60344. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  60345. }
  60346. /**
  60347. * Loader interface with additional members.
  60348. */
  60349. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  60350. }
  60351. /**
  60352. * Loader interface with additional members.
  60353. */
  60354. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  60355. baseColorTexture?: ITextureInfo;
  60356. metallicRoughnessTexture?: ITextureInfo;
  60357. }
  60358. /**
  60359. * Loader interface with additional members.
  60360. */
  60361. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  60362. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  60363. normalTexture?: IMaterialNormalTextureInfo;
  60364. occlusionTexture?: IMaterialOcclusionTextureInfo;
  60365. emissiveTexture?: ITextureInfo;
  60366. /** @hidden */ data?: {
  60367. [babylonDrawMode: number]: {
  60368. babylonMaterial: Material;
  60369. babylonMeshes: AbstractMesh[];
  60370. promise: Promise<void>;
  60371. };
  60372. };
  60373. }
  60374. /**
  60375. * Loader interface with additional members.
  60376. */
  60377. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  60378. primitives: IMeshPrimitive[];
  60379. }
  60380. /**
  60381. * Loader interface with additional members.
  60382. */
  60383. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  60384. /** @hidden */ instanceData?: {
  60385. babylonSourceMesh: Mesh;
  60386. promise: Promise<any>;
  60387. };
  60388. }
  60389. /**
  60390. * Loader interface with additional members.
  60391. */
  60392. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  60393. /**
  60394. * The parent glTF node.
  60395. */
  60396. parent?: INode;
  60397. /** @hidden */ babylonTransformNode?: TransformNode;
  60398. /** @hidden */ primitiveBabylonMeshes?: AbstractMesh[];
  60399. /** @hidden */ babylonBones?: Bone[];
  60400. /** @hidden */ numMorphTargets?: number;
  60401. }
  60402. /** @hidden */
  60403. export interface _ISamplerData {
  60404. noMipMaps: boolean;
  60405. samplingMode: number;
  60406. wrapU: number;
  60407. wrapV: number;
  60408. }
  60409. /**
  60410. * Loader interface with additional members.
  60411. */
  60412. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  60413. /** @hidden */ data?: _ISamplerData;
  60414. }
  60415. /**
  60416. * Loader interface with additional members.
  60417. */
  60418. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  60419. }
  60420. /**
  60421. * Loader interface with additional members.
  60422. */
  60423. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  60424. /** @hidden */ data?: {
  60425. babylonSkeleton: Skeleton;
  60426. promise: Promise<void>;
  60427. };
  60428. }
  60429. /**
  60430. * Loader interface with additional members.
  60431. */
  60432. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  60433. }
  60434. /**
  60435. * Loader interface with additional members.
  60436. */
  60437. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  60438. }
  60439. /**
  60440. * Loader interface with additional members.
  60441. */
  60442. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  60443. accessors?: IAccessor[];
  60444. animations?: IAnimation[];
  60445. buffers?: IBuffer[];
  60446. bufferViews?: IBufferView[];
  60447. cameras?: ICamera[];
  60448. images?: IImage[];
  60449. materials?: IMaterial[];
  60450. meshes?: IMesh[];
  60451. nodes?: INode[];
  60452. samplers?: ISampler[];
  60453. scenes?: IScene[];
  60454. skins?: ISkin[];
  60455. textures?: ITexture[];
  60456. }
  60457. }
  60458. declare module BABYLON.GLTF2 {
  60459. /**
  60460. * Interface for a glTF loader extension.
  60461. */
  60462. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  60463. /**
  60464. * Called after the loader state changes to LOADING.
  60465. */
  60466. onLoading?(): void;
  60467. /**
  60468. * Called after the loader state changes to READY.
  60469. */
  60470. onReady?(): void;
  60471. /**
  60472. * Define this method to modify the default behavior when loading scenes.
  60473. * @param context The context when loading the asset
  60474. * @param scene The glTF scene property
  60475. * @returns A promise that resolves when the load is complete or null if not handled
  60476. */
  60477. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  60478. /**
  60479. * Define this method to modify the default behavior when loading nodes.
  60480. * @param context The context when loading the asset
  60481. * @param node The glTF node property
  60482. * @param assign A function called synchronously after parsing the glTF properties
  60483. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  60484. */
  60485. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  60486. /**
  60487. * Define this method to modify the default behavior when loading cameras.
  60488. * @param context The context when loading the asset
  60489. * @param camera The glTF camera property
  60490. * @param assign A function called synchronously after parsing the glTF properties
  60491. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  60492. */
  60493. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  60494. /**
  60495. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  60496. * @param context The context when loading the asset
  60497. * @param primitive The glTF mesh primitive property
  60498. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  60499. */ loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  60500. /**
  60501. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  60502. * @param context The context when loading the asset
  60503. * @param material The glTF material property
  60504. * @param assign A function called synchronously after parsing the glTF properties
  60505. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  60506. */ loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  60507. /**
  60508. * Define this method to modify the default behavior when creating materials.
  60509. * @param context The context when loading the asset
  60510. * @param material The glTF material property
  60511. * @param babylonDrawMode The draw mode for the Babylon material
  60512. * @returns The Babylon material or null if not handled
  60513. */
  60514. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  60515. /**
  60516. * Define this method to modify the default behavior when loading material properties.
  60517. * @param context The context when loading the asset
  60518. * @param material The glTF material property
  60519. * @param babylonMaterial The Babylon material
  60520. * @returns A promise that resolves when the load is complete or null if not handled
  60521. */
  60522. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  60523. /**
  60524. * Define this method to modify the default behavior when loading texture infos.
  60525. * @param context The context when loading the asset
  60526. * @param textureInfo The glTF texture info property
  60527. * @param assign A function called synchronously after parsing the glTF properties
  60528. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  60529. */
  60530. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  60531. /**
  60532. * Define this method to modify the default behavior when loading animations.
  60533. * @param context The context when loading the asset
  60534. * @param animation The glTF animation property
  60535. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  60536. */
  60537. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  60538. /**
  60539. * Define this method to modify the default behavior when loading skins.
  60540. * @param context The context when loading the asset
  60541. * @param node The glTF node property
  60542. * @param skin The glTF skin property
  60543. * @returns A promise that resolves when the load is complete or null if not handled
  60544. */ loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  60545. /**
  60546. * Define this method to modify the default behavior when loading uris.
  60547. * @param context The context when loading the asset
  60548. * @param property The glTF property associated with the uri
  60549. * @param uri The uri to load
  60550. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  60551. */ loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  60552. }
  60553. }
  60554. declare module BABYLON.GLTF2 {
  60555. /**
  60556. * Helper class for working with arrays when loading the glTF asset
  60557. */
  60558. export class ArrayItem {
  60559. /**
  60560. * Gets an item from the given array.
  60561. * @param context The context when loading the asset
  60562. * @param array The array to get the item from
  60563. * @param index The index to the array
  60564. * @returns The array item
  60565. */
  60566. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  60567. /**
  60568. * Assign an `index` field to each item of the given array.
  60569. * @param array The array of items
  60570. */
  60571. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  60572. }
  60573. /**
  60574. * The glTF 2.0 loader
  60575. */
  60576. export class GLTFLoader implements IGLTFLoader {
  60577. /** @hidden */ completePromises: Promise<any>[];
  60578. private _disposed;
  60579. private _parent;
  60580. private _state;
  60581. private _extensions;
  60582. private _rootUrl;
  60583. private _fileName;
  60584. private _uniqueRootUrl;
  60585. private _gltf;
  60586. private _babylonScene;
  60587. private _rootBabylonMesh;
  60588. private _defaultBabylonMaterialData;
  60589. private _progressCallback?;
  60590. private _requests;
  60591. private static readonly _DefaultSampler;
  60592. private static _ExtensionNames;
  60593. private static _ExtensionFactories;
  60594. /**
  60595. * Registers a loader extension.
  60596. * @param name The name of the loader extension.
  60597. * @param factory The factory function that creates the loader extension.
  60598. */
  60599. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  60600. /**
  60601. * Unregisters a loader extension.
  60602. * @param name The name of the loader extenion.
  60603. * @returns A boolean indicating whether the extension has been unregistered
  60604. */
  60605. static UnregisterExtension(name: string): boolean;
  60606. /**
  60607. * Gets the loader state.
  60608. */
  60609. readonly state: Nullable<GLTFLoaderState>;
  60610. /**
  60611. * The glTF object parsed from the JSON.
  60612. */
  60613. readonly gltf: IGLTF;
  60614. /**
  60615. * The Babylon scene when loading the asset.
  60616. */
  60617. readonly babylonScene: Scene;
  60618. /**
  60619. * The root Babylon mesh when loading the asset.
  60620. */
  60621. readonly rootBabylonMesh: Mesh;
  60622. /** @hidden */
  60623. constructor(parent: GLTFFileLoader);
  60624. /** @hidden */
  60625. dispose(): void;
  60626. /** @hidden */
  60627. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  60628. meshes: AbstractMesh[];
  60629. particleSystems: IParticleSystem[];
  60630. skeletons: Skeleton[];
  60631. animationGroups: AnimationGroup[];
  60632. }>;
  60633. /** @hidden */
  60634. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  60635. private _loadAsync;
  60636. private _loadData;
  60637. private _setupData;
  60638. private _loadExtensions;
  60639. private _checkExtensions;
  60640. private _setState;
  60641. private _createRootNode;
  60642. /**
  60643. * Loads a glTF scene.
  60644. * @param context The context when loading the asset
  60645. * @param scene The glTF scene property
  60646. * @returns A promise that resolves when the load is complete
  60647. */
  60648. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  60649. private _forEachPrimitive;
  60650. private _getMeshes;
  60651. private _getSkeletons;
  60652. private _getAnimationGroups;
  60653. private _startAnimations;
  60654. /**
  60655. * Loads a glTF node.
  60656. * @param context The context when loading the asset
  60657. * @param node The glTF node property
  60658. * @param assign A function called synchronously after parsing the glTF properties
  60659. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  60660. */
  60661. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  60662. private _loadMeshAsync;
  60663. private _loadMeshPrimitiveAsync;
  60664. private _loadVertexDataAsync;
  60665. private _createMorphTargets;
  60666. private _loadMorphTargetsAsync;
  60667. private _loadMorphTargetVertexDataAsync;
  60668. private static _LoadTransform;
  60669. private _loadSkinAsync;
  60670. private _loadBones;
  60671. private _loadBone;
  60672. private _loadSkinInverseBindMatricesDataAsync;
  60673. private _updateBoneMatrices;
  60674. private _getNodeMatrix;
  60675. /**
  60676. * Loads a glTF camera.
  60677. * @param context The context when loading the asset
  60678. * @param camera The glTF camera property
  60679. * @param assign A function called synchronously after parsing the glTF properties
  60680. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  60681. */
  60682. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  60683. private _loadAnimationsAsync;
  60684. /**
  60685. * Loads a glTF animation.
  60686. * @param context The context when loading the asset
  60687. * @param animation The glTF animation property
  60688. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  60689. */
  60690. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  60691. private _loadAnimationChannelAsync;
  60692. private _loadAnimationSamplerAsync;
  60693. private _loadBufferAsync;
  60694. /**
  60695. * Loads a glTF buffer view.
  60696. * @param context The context when loading the asset
  60697. * @param bufferView The glTF buffer view property
  60698. * @returns A promise that resolves with the loaded data when the load is complete
  60699. */
  60700. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  60701. private _loadIndicesAccessorAsync;
  60702. private _loadFloatAccessorAsync;
  60703. private _loadVertexBufferViewAsync;
  60704. private _loadVertexAccessorAsync;
  60705. private _loadMaterialMetallicRoughnessPropertiesAsync;
  60706. /** @hidden */ loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  60707. private _createDefaultMaterial;
  60708. /**
  60709. * Creates a Babylon material from a glTF material.
  60710. * @param context The context when loading the asset
  60711. * @param material The glTF material property
  60712. * @param babylonDrawMode The draw mode for the Babylon material
  60713. * @returns The Babylon material
  60714. */
  60715. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  60716. /**
  60717. * Loads properties from a glTF material into a Babylon material.
  60718. * @param context The context when loading the asset
  60719. * @param material The glTF material property
  60720. * @param babylonMaterial The Babylon material
  60721. * @returns A promise that resolves when the load is complete
  60722. */
  60723. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  60724. /**
  60725. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  60726. * @param context The context when loading the asset
  60727. * @param material The glTF material property
  60728. * @param babylonMaterial The Babylon material
  60729. * @returns A promise that resolves when the load is complete
  60730. */
  60731. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  60732. /**
  60733. * Loads the alpha properties from a glTF material into a Babylon material.
  60734. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  60735. * @param context The context when loading the asset
  60736. * @param material The glTF material property
  60737. * @param babylonMaterial The Babylon material
  60738. */
  60739. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  60740. /**
  60741. * Loads a glTF texture info.
  60742. * @param context The context when loading the asset
  60743. * @param textureInfo The glTF texture info property
  60744. * @param assign A function called synchronously after parsing the glTF properties
  60745. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  60746. */
  60747. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  60748. private _loadTextureAsync;
  60749. private _loadSampler;
  60750. /**
  60751. * Loads a glTF image.
  60752. * @param context The context when loading the asset
  60753. * @param image The glTF image property
  60754. * @returns A promise that resolves with the loaded data when the load is complete
  60755. */
  60756. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  60757. /**
  60758. * Loads a glTF uri.
  60759. * @param context The context when loading the asset
  60760. * @param property The glTF property associated with the uri
  60761. * @param uri The base64 or relative uri
  60762. * @returns A promise that resolves with the loaded data when the load is complete
  60763. */
  60764. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  60765. private _onProgress;
  60766. /**
  60767. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  60768. * @param babylonObject the Babylon object with metadata
  60769. * @param pointer the JSON pointer
  60770. */
  60771. static AddPointerMetadata(babylonObject: {
  60772. metadata: any;
  60773. }, pointer: string): void;
  60774. private static _GetTextureWrapMode;
  60775. private static _GetTextureSamplingMode;
  60776. private static _GetTypedArray;
  60777. private static _GetNumComponents;
  60778. private static _ValidateUri;
  60779. private static _GetDrawMode;
  60780. private _compileMaterialsAsync;
  60781. private _compileShadowGeneratorsAsync;
  60782. private _forEachExtensions;
  60783. private _applyExtensions;
  60784. private _extensionsOnLoading;
  60785. private _extensionsOnReady;
  60786. private _extensionsLoadSceneAsync;
  60787. private _extensionsLoadNodeAsync;
  60788. private _extensionsLoadCameraAsync;
  60789. private _extensionsLoadVertexDataAsync;
  60790. private _extensionsLoadMaterialAsync;
  60791. private _extensionsCreateMaterial;
  60792. private _extensionsLoadMaterialPropertiesAsync;
  60793. private _extensionsLoadTextureInfoAsync;
  60794. private _extensionsLoadAnimationAsync;
  60795. private _extensionsLoadSkinAsync;
  60796. private _extensionsLoadUriAsync;
  60797. /**
  60798. * Helper method called by a loader extension to load an glTF extension.
  60799. * @param context The context when loading the asset
  60800. * @param property The glTF property to load the extension from
  60801. * @param extensionName The name of the extension to load
  60802. * @param actionAsync The action to run
  60803. * @returns The promise returned by actionAsync or null if the extension does not exist
  60804. */
  60805. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  60806. /**
  60807. * Helper method called by a loader extension to load a glTF extra.
  60808. * @param context The context when loading the asset
  60809. * @param property The glTF property to load the extra from
  60810. * @param extensionName The name of the extension to load
  60811. * @param actionAsync The action to run
  60812. * @returns The promise returned by actionAsync or null if the extra does not exist
  60813. */
  60814. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  60815. /**
  60816. * Increments the indentation level and logs a message.
  60817. * @param message The message to log
  60818. */
  60819. logOpen(message: string): void;
  60820. /**
  60821. * Decrements the indentation level.
  60822. */
  60823. logClose(): void;
  60824. /**
  60825. * Logs a message
  60826. * @param message The message to log
  60827. */
  60828. log(message: string): void;
  60829. /**
  60830. * Starts a performance counter.
  60831. * @param counterName The name of the performance counter
  60832. */
  60833. startPerformanceCounter(counterName: string): void;
  60834. /**
  60835. * Ends a performance counter.
  60836. * @param counterName The name of the performance counter
  60837. */
  60838. endPerformanceCounter(counterName: string): void;
  60839. }
  60840. }
  60841. declare module BABYLON.GLTF2.Loader.Extensions {
  60842. /**
  60843. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  60844. */
  60845. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  60846. /** The name of this extension. */
  60847. readonly name: string;
  60848. /** Defines whether this extension is enabled. */
  60849. enabled: boolean;
  60850. private _loader;
  60851. private _lights?;
  60852. /** @hidden */
  60853. constructor(loader: GLTFLoader);
  60854. /** @hidden */
  60855. dispose(): void;
  60856. /** @hidden */
  60857. onLoading(): void;
  60858. /** @hidden */
  60859. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  60860. private _loadLightAsync;
  60861. }
  60862. }
  60863. declare module BABYLON.GLTF2.Loader.Extensions {
  60864. /**
  60865. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  60866. */
  60867. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  60868. /** The name of this extension. */
  60869. readonly name: string;
  60870. /** The draco compression used to decode vertex data. */
  60871. dracoCompression?: DracoCompression;
  60872. /** Defines whether this extension is enabled. */
  60873. enabled: boolean;
  60874. private _loader;
  60875. private _dracoCompressionOwned;
  60876. /** @hidden */
  60877. constructor(loader: GLTFLoader);
  60878. /** @hidden */
  60879. dispose(): void;
  60880. /** @hidden */ loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  60881. }
  60882. }
  60883. declare module BABYLON.GLTF2.Loader.Extensions {
  60884. /**
  60885. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  60886. */
  60887. export class KHR_lights implements IGLTFLoaderExtension {
  60888. /** The name of this extension. */
  60889. readonly name: string;
  60890. /** Defines whether this extension is enabled. */
  60891. enabled: boolean;
  60892. private _loader;
  60893. private _lights?;
  60894. /** @hidden */
  60895. constructor(loader: GLTFLoader);
  60896. /** @hidden */
  60897. dispose(): void;
  60898. /** @hidden */
  60899. onLoading(): void;
  60900. /** @hidden */
  60901. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  60902. }
  60903. }
  60904. declare module BABYLON.GLTF2.Loader.Extensions {
  60905. /**
  60906. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  60907. */
  60908. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  60909. /** The name of this extension. */
  60910. readonly name: string;
  60911. /** Defines whether this extension is enabled. */
  60912. enabled: boolean;
  60913. private _loader;
  60914. /** @hidden */
  60915. constructor(loader: GLTFLoader);
  60916. /** @hidden */
  60917. dispose(): void;
  60918. /** @hidden */
  60919. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  60920. private _loadSpecularGlossinessPropertiesAsync;
  60921. }
  60922. }
  60923. declare module BABYLON.GLTF2.Loader.Extensions {
  60924. /**
  60925. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  60926. */
  60927. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  60928. /** The name of this extension. */
  60929. readonly name: string;
  60930. /** Defines whether this extension is enabled. */
  60931. enabled: boolean;
  60932. private _loader;
  60933. /** @hidden */
  60934. constructor(loader: GLTFLoader);
  60935. /** @hidden */
  60936. dispose(): void;
  60937. /** @hidden */
  60938. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  60939. private _loadUnlitPropertiesAsync;
  60940. }
  60941. }
  60942. declare module BABYLON.GLTF2.Loader.Extensions {
  60943. /**
  60944. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  60945. */
  60946. export class KHR_texture_transform implements IGLTFLoaderExtension {
  60947. /** The name of this extension. */
  60948. readonly name: string;
  60949. /** Defines whether this extension is enabled. */
  60950. enabled: boolean;
  60951. private _loader;
  60952. /** @hidden */
  60953. constructor(loader: GLTFLoader);
  60954. /** @hidden */
  60955. dispose(): void;
  60956. /** @hidden */
  60957. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  60958. }
  60959. }
  60960. declare module BABYLON.GLTF2.Loader.Extensions {
  60961. /**
  60962. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  60963. */
  60964. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  60965. /** The name of this extension. */
  60966. readonly name: string;
  60967. /** Defines whether this extension is enabled. */
  60968. enabled: boolean;
  60969. private _loader;
  60970. private _clips;
  60971. private _emitters;
  60972. /** @hidden */
  60973. constructor(loader: GLTFLoader);
  60974. /** @hidden */
  60975. dispose(): void;
  60976. /** @hidden */
  60977. onLoading(): void;
  60978. /** @hidden */
  60979. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  60980. /** @hidden */
  60981. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  60982. /** @hidden */
  60983. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  60984. private _loadClipAsync;
  60985. private _loadEmitterAsync;
  60986. private _getEventAction;
  60987. private _loadAnimationEventAsync;
  60988. }
  60989. }
  60990. declare module BABYLON.GLTF2.Loader.Extensions {
  60991. /**
  60992. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  60993. */
  60994. export class MSFT_lod implements IGLTFLoaderExtension {
  60995. /** The name of this extension. */
  60996. readonly name: string;
  60997. /** Defines whether this extension is enabled. */
  60998. enabled: boolean;
  60999. /**
  61000. * Maximum number of LODs to load, starting from the lowest LOD.
  61001. */
  61002. maxLODsToLoad: number;
  61003. /**
  61004. * Observable raised when all node LODs of one level are loaded.
  61005. * The event data is the index of the loaded LOD starting from zero.
  61006. * Dispose the loader to cancel the loading of the next level of LODs.
  61007. */
  61008. onNodeLODsLoadedObservable: Observable<number>;
  61009. /**
  61010. * Observable raised when all material LODs of one level are loaded.
  61011. * The event data is the index of the loaded LOD starting from zero.
  61012. * Dispose the loader to cancel the loading of the next level of LODs.
  61013. */
  61014. onMaterialLODsLoadedObservable: Observable<number>;
  61015. private _loader;
  61016. private _nodeIndexLOD;
  61017. private _nodeSignalLODs;
  61018. private _nodePromiseLODs;
  61019. private _materialIndexLOD;
  61020. private _materialSignalLODs;
  61021. private _materialPromiseLODs;
  61022. /** @hidden */
  61023. constructor(loader: GLTFLoader);
  61024. /** @hidden */
  61025. dispose(): void;
  61026. /** @hidden */
  61027. onReady(): void;
  61028. /** @hidden */
  61029. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  61030. /** @hidden */ loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  61031. /** @hidden */ loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  61032. /**
  61033. * Gets an array of LOD properties from lowest to highest.
  61034. */
  61035. private _getLODs;
  61036. private _disposeUnusedMaterials;
  61037. }
  61038. }
  61039. declare module BABYLON.GLTF2.Loader.Extensions {
  61040. /** @hidden */
  61041. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  61042. readonly name: string;
  61043. enabled: boolean;
  61044. private _loader;
  61045. constructor(loader: GLTFLoader);
  61046. dispose(): void;
  61047. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  61048. }
  61049. }
  61050. declare module BABYLON.GLTF2.Loader.Extensions {
  61051. /** @hidden */
  61052. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  61053. readonly name: string;
  61054. enabled: boolean;
  61055. private _loader;
  61056. constructor(loader: GLTFLoader);
  61057. dispose(): void;
  61058. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  61059. }
  61060. }
  61061. declare module BABYLON {
  61062. /**
  61063. * Class reading and parsing the MTL file bundled with the obj file.
  61064. */
  61065. export class MTLFileLoader {
  61066. /**
  61067. * All material loaded from the mtl will be set here
  61068. */
  61069. materials: StandardMaterial[];
  61070. /**
  61071. * This function will read the mtl file and create each material described inside
  61072. * This function could be improve by adding :
  61073. * -some component missing (Ni, Tf...)
  61074. * -including the specific options available
  61075. *
  61076. * @param scene defines the scene the material will be created in
  61077. * @param data defines the mtl data to parse
  61078. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  61079. */
  61080. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  61081. /**
  61082. * Gets the texture for the material.
  61083. *
  61084. * If the material is imported from input file,
  61085. * We sanitize the url to ensure it takes the textre from aside the material.
  61086. *
  61087. * @param rootUrl The root url to load from
  61088. * @param value The value stored in the mtl
  61089. * @return The Texture
  61090. */
  61091. private static _getTexture;
  61092. }
  61093. /**
  61094. * Options for loading OBJ/MTL files
  61095. */
  61096. type MeshLoadOptions = {
  61097. /**
  61098. * Defines if UVs are optimized by default during load.
  61099. */
  61100. OptimizeWithUV: boolean;
  61101. /**
  61102. * Invert model on y-axis (does a model scaling inversion)
  61103. */
  61104. InvertY: boolean;
  61105. /**
  61106. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  61107. */
  61108. ImportVertexColors: boolean;
  61109. /**
  61110. * Compute the normals for the model, even if normals are present in the file.
  61111. */
  61112. ComputeNormals: boolean;
  61113. /**
  61114. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  61115. */
  61116. SkipMaterials: boolean;
  61117. /**
  61118. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  61119. */
  61120. MaterialLoadingFailsSilently: boolean;
  61121. };
  61122. /**
  61123. * OBJ file type loader.
  61124. * This is a babylon scene loader plugin.
  61125. */
  61126. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  61127. /**
  61128. * Defines if UVs are optimized by default during load.
  61129. */
  61130. static OPTIMIZE_WITH_UV: boolean;
  61131. /**
  61132. * Invert model on y-axis (does a model scaling inversion)
  61133. */
  61134. static INVERT_Y: boolean;
  61135. /**
  61136. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  61137. */
  61138. static IMPORT_VERTEX_COLORS: boolean;
  61139. /**
  61140. * Compute the normals for the model, even if normals are present in the file.
  61141. */
  61142. static COMPUTE_NORMALS: boolean;
  61143. /**
  61144. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  61145. */
  61146. static SKIP_MATERIALS: boolean;
  61147. /**
  61148. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  61149. *
  61150. * Defaults to true for backwards compatibility.
  61151. */
  61152. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  61153. /**
  61154. * Defines the name of the plugin.
  61155. */
  61156. name: string;
  61157. /**
  61158. * Defines the extension the plugin is able to load.
  61159. */
  61160. extensions: string;
  61161. /** @hidden */
  61162. obj: RegExp;
  61163. /** @hidden */
  61164. group: RegExp;
  61165. /** @hidden */
  61166. mtllib: RegExp;
  61167. /** @hidden */
  61168. usemtl: RegExp;
  61169. /** @hidden */
  61170. smooth: RegExp;
  61171. /** @hidden */
  61172. vertexPattern: RegExp;
  61173. /** @hidden */
  61174. normalPattern: RegExp;
  61175. /** @hidden */
  61176. uvPattern: RegExp;
  61177. /** @hidden */
  61178. facePattern1: RegExp;
  61179. /** @hidden */
  61180. facePattern2: RegExp;
  61181. /** @hidden */
  61182. facePattern3: RegExp;
  61183. /** @hidden */
  61184. facePattern4: RegExp;
  61185. /** @hidden */
  61186. facePattern5: RegExp;
  61187. private _meshLoadOptions;
  61188. /**
  61189. * Creates loader for .OBJ files
  61190. *
  61191. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  61192. */
  61193. constructor(meshLoadOptions?: MeshLoadOptions);
  61194. private static readonly currentMeshLoadOptions;
  61195. /**
  61196. * Calls synchronously the MTL file attached to this obj.
  61197. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  61198. * Without this function materials are not displayed in the first frame (but displayed after).
  61199. * In consequence it is impossible to get material information in your HTML file
  61200. *
  61201. * @param url The URL of the MTL file
  61202. * @param rootUrl
  61203. * @param onSuccess Callback function to be called when the MTL file is loaded
  61204. * @private
  61205. */
  61206. private _loadMTL;
  61207. /**
  61208. * Instantiates a OBJ file loader plugin.
  61209. * @returns the created plugin
  61210. */
  61211. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  61212. /**
  61213. * If the data string can be loaded directly.
  61214. *
  61215. * @param data string containing the file data
  61216. * @returns if the data can be loaded directly
  61217. */
  61218. canDirectLoad(data: string): boolean;
  61219. /**
  61220. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  61221. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  61222. * @param scene the scene the meshes should be added to
  61223. * @param data the OBJ data to load
  61224. * @param rootUrl root url to load from
  61225. * @param onProgress event that fires when loading progress has occured
  61226. * @param fileName Defines the name of the file to load
  61227. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  61228. */
  61229. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  61230. meshes: AbstractMesh[];
  61231. particleSystems: IParticleSystem[];
  61232. skeletons: Skeleton[];
  61233. animationGroups: AnimationGroup[];
  61234. }>;
  61235. /**
  61236. * Imports all objects from the loaded OBJ data and adds them to the scene
  61237. * @param scene the scene the objects should be added to
  61238. * @param data the OBJ data to load
  61239. * @param rootUrl root url to load from
  61240. * @param onProgress event that fires when loading progress has occured
  61241. * @param fileName Defines the name of the file to load
  61242. * @returns a promise which completes when objects have been loaded to the scene
  61243. */
  61244. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  61245. /**
  61246. * Load into an asset container.
  61247. * @param scene The scene to load into
  61248. * @param data The data to import
  61249. * @param rootUrl The root url for scene and resources
  61250. * @param onProgress The callback when the load progresses
  61251. * @param fileName Defines the name of the file to load
  61252. * @returns The loaded asset container
  61253. */
  61254. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  61255. /**
  61256. * Read the OBJ file and create an Array of meshes.
  61257. * Each mesh contains all information given by the OBJ and the MTL file.
  61258. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  61259. *
  61260. * @param meshesNames
  61261. * @param scene Scene The scene where are displayed the data
  61262. * @param data String The content of the obj file
  61263. * @param rootUrl String The path to the folder
  61264. * @returns Array<AbstractMesh>
  61265. * @private
  61266. */
  61267. private _parseSolid;
  61268. }
  61269. }
  61270. declare module BABYLON {
  61271. /**
  61272. * STL file type loader.
  61273. * This is a babylon scene loader plugin.
  61274. */
  61275. export class STLFileLoader implements ISceneLoaderPlugin {
  61276. /** @hidden */
  61277. solidPattern: RegExp;
  61278. /** @hidden */
  61279. facetsPattern: RegExp;
  61280. /** @hidden */
  61281. normalPattern: RegExp;
  61282. /** @hidden */
  61283. vertexPattern: RegExp;
  61284. /**
  61285. * Defines the name of the plugin.
  61286. */
  61287. name: string;
  61288. /**
  61289. * Defines the extensions the stl loader is able to load.
  61290. * force data to come in as an ArrayBuffer
  61291. * we'll convert to string if it looks like it's an ASCII .stl
  61292. */
  61293. extensions: ISceneLoaderPluginExtensions;
  61294. /**
  61295. * Import meshes into a scene.
  61296. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  61297. * @param scene The scene to import into
  61298. * @param data The data to import
  61299. * @param rootUrl The root url for scene and resources
  61300. * @param meshes The meshes array to import into
  61301. * @param particleSystems The particle systems array to import into
  61302. * @param skeletons The skeletons array to import into
  61303. * @param onError The callback when import fails
  61304. * @returns True if successful or false otherwise
  61305. */
  61306. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  61307. /**
  61308. * Load into a scene.
  61309. * @param scene The scene to load into
  61310. * @param data The data to import
  61311. * @param rootUrl The root url for scene and resources
  61312. * @param onError The callback when import fails
  61313. * @returns true if successful or false otherwise
  61314. */
  61315. load(scene: Scene, data: any, rootUrl: string): boolean;
  61316. /**
  61317. * Load into an asset container.
  61318. * @param scene The scene to load into
  61319. * @param data The data to import
  61320. * @param rootUrl The root url for scene and resources
  61321. * @param onError The callback when import fails
  61322. * @returns The loaded asset container
  61323. */
  61324. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  61325. private _isBinary;
  61326. private _parseBinary;
  61327. private _parseASCII;
  61328. }
  61329. }
  61330. declare module BABYLON {
  61331. /**
  61332. * Class for generating OBJ data from a Babylon scene.
  61333. */
  61334. export class OBJExport {
  61335. /**
  61336. * Exports the geometry of a Mesh array in .OBJ file format (text)
  61337. * @param mesh defines the list of meshes to serialize
  61338. * @param materials defines if materials should be exported
  61339. * @param matlibname defines the name of the associated mtl file
  61340. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  61341. * @returns the OBJ content
  61342. */
  61343. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  61344. /**
  61345. * Exports the material(s) of a mesh in .MTL file format (text)
  61346. * @param mesh defines the mesh to extract the material from
  61347. * @returns the mtl content
  61348. */
  61349. static MTL(mesh: Mesh): string;
  61350. }
  61351. }
  61352. declare module BABYLON {
  61353. /** @hidden */
  61354. export var __IGLTFExporterExtension: number;
  61355. /**
  61356. * Interface for extending the exporter
  61357. * @hidden
  61358. */
  61359. export interface IGLTFExporterExtension {
  61360. /**
  61361. * The name of this extension
  61362. */
  61363. readonly name: string;
  61364. /**
  61365. * Defines whether this extension is enabled
  61366. */
  61367. enabled: boolean;
  61368. /**
  61369. * Defines whether this extension is required
  61370. */
  61371. required: boolean;
  61372. }
  61373. }
  61374. declare module BABYLON.GLTF2.Exporter {
  61375. /** @hidden */
  61376. export var __IGLTFExporterExtensionV2: number;
  61377. /**
  61378. * Interface for a glTF exporter extension
  61379. * @hidden
  61380. */
  61381. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  61382. /**
  61383. * Define this method to modify the default behavior before exporting a texture
  61384. * @param context The context when loading the asset
  61385. * @param babylonTexture The glTF texture info property
  61386. * @param mimeType The mime-type of the generated image
  61387. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  61388. */
  61389. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  61390. /**
  61391. * Define this method to modify the default behavior when exporting texture info
  61392. * @param context The context when loading the asset
  61393. * @param meshPrimitive glTF mesh primitive
  61394. * @param babylonSubMesh Babylon submesh
  61395. * @param binaryWriter glTF serializer binary writer instance
  61396. * @returns nullable IMeshPrimitive promise
  61397. */
  61398. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  61399. /**
  61400. * Define this method to modify the default behavior when exporting a node
  61401. * @param context The context when exporting the node
  61402. * @param node glTF node
  61403. * @param babylonNode BabylonJS node
  61404. * @returns nullable INode promise
  61405. */
  61406. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  61407. /**
  61408. * Called after the exporter state changes to EXPORTING
  61409. */
  61410. onExporting?(): void;
  61411. }
  61412. }
  61413. declare module BABYLON.GLTF2.Exporter {
  61414. /**
  61415. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  61416. * @hidden
  61417. */
  61418. export class _GLTFMaterialExporter {
  61419. /**
  61420. * Represents the dielectric specular values for R, G and B
  61421. */
  61422. private static readonly _DielectricSpecular;
  61423. /**
  61424. * Allows the maximum specular power to be defined for material calculations
  61425. */
  61426. private static readonly _MaxSpecularPower;
  61427. /**
  61428. * Mapping to store textures
  61429. */
  61430. private _textureMap;
  61431. /**
  61432. * Numeric tolerance value
  61433. */
  61434. private static readonly _Epsilon;
  61435. /**
  61436. * Reference to the glTF Exporter
  61437. */
  61438. private _exporter;
  61439. constructor(exporter: _Exporter);
  61440. /**
  61441. * Specifies if two colors are approximately equal in value
  61442. * @param color1 first color to compare to
  61443. * @param color2 second color to compare to
  61444. * @param epsilon threshold value
  61445. */
  61446. private static FuzzyEquals;
  61447. /**
  61448. * Gets the materials from a Babylon scene and converts them to glTF materials
  61449. * @param scene babylonjs scene
  61450. * @param mimeType texture mime type
  61451. * @param images array of images
  61452. * @param textures array of textures
  61453. * @param materials array of materials
  61454. * @param imageData mapping of texture names to base64 textures
  61455. * @param hasTextureCoords specifies if texture coordinates are present on the material
  61456. */ convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61457. /**
  61458. * Makes a copy of the glTF material without the texture parameters
  61459. * @param originalMaterial original glTF material
  61460. * @returns glTF material without texture parameters
  61461. */ stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  61462. /**
  61463. * Specifies if the material has any texture parameters present
  61464. * @param material glTF Material
  61465. * @returns boolean specifying if texture parameters are present
  61466. */ hasTexturesPresent(material: IMaterial): boolean;
  61467. /**
  61468. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  61469. * @param babylonStandardMaterial
  61470. * @returns glTF Metallic Roughness Material representation
  61471. */ convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  61472. /**
  61473. * Computes the metallic factor
  61474. * @param diffuse diffused value
  61475. * @param specular specular value
  61476. * @param oneMinusSpecularStrength one minus the specular strength
  61477. * @returns metallic value
  61478. */ private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  61479. /**
  61480. * Gets the glTF alpha mode from the Babylon Material
  61481. * @param babylonMaterial Babylon Material
  61482. * @returns The Babylon alpha mode value
  61483. */ getAlphaMode(babylonMaterial: Material): MaterialAlphaMode;
  61484. /**
  61485. * Converts a Babylon Standard Material to a glTF Material
  61486. * @param babylonStandardMaterial BJS Standard Material
  61487. * @param mimeType mime type to use for the textures
  61488. * @param images array of glTF image interfaces
  61489. * @param textures array of glTF texture interfaces
  61490. * @param materials array of glTF material interfaces
  61491. * @param imageData map of image file name to data
  61492. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61493. */ convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61494. /**
  61495. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  61496. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  61497. * @param mimeType mime type to use for the textures
  61498. * @param images array of glTF image interfaces
  61499. * @param textures array of glTF texture interfaces
  61500. * @param materials array of glTF material interfaces
  61501. * @param imageData map of image file name to data
  61502. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61503. */ convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61504. /**
  61505. * Converts an image typed array buffer to a base64 image
  61506. * @param buffer typed array buffer
  61507. * @param width width of the image
  61508. * @param height height of the image
  61509. * @param mimeType mimetype of the image
  61510. * @returns base64 image string
  61511. */
  61512. private _createBase64FromCanvasAsync;
  61513. /**
  61514. * Generates a white texture based on the specified width and height
  61515. * @param width width of the texture in pixels
  61516. * @param height height of the texture in pixels
  61517. * @param scene babylonjs scene
  61518. * @returns white texture
  61519. */
  61520. private _createWhiteTexture;
  61521. /**
  61522. * 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
  61523. * @param texture1 first texture to resize
  61524. * @param texture2 second texture to resize
  61525. * @param scene babylonjs scene
  61526. * @returns resized textures or null
  61527. */
  61528. private _resizeTexturesToSameDimensions;
  61529. /**
  61530. * Converts an array of pixels to a Float32Array
  61531. * Throws an error if the pixel format is not supported
  61532. * @param pixels - array buffer containing pixel values
  61533. * @returns Float32 of pixels
  61534. */
  61535. private _convertPixelArrayToFloat32;
  61536. /**
  61537. * Convert Specular Glossiness Textures to Metallic Roughness
  61538. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  61539. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  61540. * @param diffuseTexture texture used to store diffuse information
  61541. * @param specularGlossinessTexture texture used to store specular and glossiness information
  61542. * @param factors specular glossiness material factors
  61543. * @param mimeType the mime type to use for the texture
  61544. * @returns pbr metallic roughness interface or null
  61545. */
  61546. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  61547. /**
  61548. * Converts specular glossiness material properties to metallic roughness
  61549. * @param specularGlossiness interface with specular glossiness material properties
  61550. * @returns interface with metallic roughness material properties
  61551. */
  61552. private _convertSpecularGlossinessToMetallicRoughness;
  61553. /**
  61554. * Calculates the surface reflectance, independent of lighting conditions
  61555. * @param color Color source to calculate brightness from
  61556. * @returns number representing the perceived brightness, or zero if color is undefined
  61557. */
  61558. private _getPerceivedBrightness;
  61559. /**
  61560. * Returns the maximum color component value
  61561. * @param color
  61562. * @returns maximum color component value, or zero if color is null or undefined
  61563. */
  61564. private _getMaxComponent;
  61565. /**
  61566. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  61567. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  61568. * @param mimeType mime type to use for the textures
  61569. * @param images array of glTF image interfaces
  61570. * @param textures array of glTF texture interfaces
  61571. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  61572. * @param imageData map of image file name to data
  61573. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61574. * @returns glTF PBR Metallic Roughness factors
  61575. */
  61576. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  61577. private _getGLTFTextureSampler;
  61578. private _getGLTFTextureWrapMode;
  61579. private _getGLTFTextureWrapModesSampler;
  61580. /**
  61581. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  61582. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  61583. * @param mimeType mime type to use for the textures
  61584. * @param images array of glTF image interfaces
  61585. * @param textures array of glTF texture interfaces
  61586. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  61587. * @param imageData map of image file name to data
  61588. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61589. * @returns glTF PBR Metallic Roughness factors
  61590. */
  61591. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  61592. /**
  61593. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  61594. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  61595. * @param mimeType mime type to use for the textures
  61596. * @param images array of glTF image interfaces
  61597. * @param textures array of glTF texture interfaces
  61598. * @param materials array of glTF material interfaces
  61599. * @param imageData map of image file name to data
  61600. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61601. */ convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61602. private setMetallicRoughnessPbrMaterial;
  61603. private getPixelsFromTexture;
  61604. /**
  61605. * Extracts a texture from a Babylon texture into file data and glTF data
  61606. * @param babylonTexture Babylon texture to extract
  61607. * @param mimeType Mime Type of the babylonTexture
  61608. * @return glTF texture info, or null if the texture format is not supported
  61609. */ exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>; exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  61610. /**
  61611. * Builds a texture from base64 string
  61612. * @param base64Texture base64 texture string
  61613. * @param baseTextureName Name to use for the texture
  61614. * @param mimeType image mime type for the texture
  61615. * @param images array of images
  61616. * @param textures array of textures
  61617. * @param imageData map of image data
  61618. * @returns glTF texture info, or null if the texture format is not supported
  61619. */
  61620. private _getTextureInfoFromBase64;
  61621. }
  61622. }
  61623. declare module BABYLON {
  61624. /**
  61625. * Class for holding and downloading glTF file data
  61626. */
  61627. export class GLTFData {
  61628. /**
  61629. * Object which contains the file name as the key and its data as the value
  61630. */
  61631. glTFFiles: {
  61632. [fileName: string]: string | Blob;
  61633. };
  61634. /**
  61635. * Initializes the glTF file object
  61636. */
  61637. constructor();
  61638. /**
  61639. * Downloads the glTF data as files based on their names and data
  61640. */
  61641. downloadFiles(): void;
  61642. }
  61643. }
  61644. declare module BABYLON {
  61645. /**
  61646. * Holds a collection of exporter options and parameters
  61647. */
  61648. export interface IExportOptions {
  61649. /**
  61650. * Function which indicates whether a babylon node should be exported or not
  61651. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  61652. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  61653. */
  61654. shouldExportNode?(node: Node): boolean;
  61655. /**
  61656. * The sample rate to bake animation curves
  61657. */
  61658. animationSampleRate?: number;
  61659. /**
  61660. * Begin serialization without waiting for the scene to be ready
  61661. */
  61662. exportWithoutWaitingForScene?: boolean;
  61663. }
  61664. /**
  61665. * Class for generating glTF data from a Babylon scene.
  61666. */
  61667. export class GLTF2Export {
  61668. /**
  61669. * Exports the geometry of the scene to .gltf file format asynchronously
  61670. * @param scene Babylon scene with scene hierarchy information
  61671. * @param filePrefix File prefix to use when generating the glTF file
  61672. * @param options Exporter options
  61673. * @returns Returns an object with a .gltf file and associates texture names
  61674. * as keys and their data and paths as values
  61675. */
  61676. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  61677. private static _PreExportAsync;
  61678. private static _PostExportAsync;
  61679. /**
  61680. * Exports the geometry of the scene to .glb file format asychronously
  61681. * @param scene Babylon scene with scene hierarchy information
  61682. * @param filePrefix File prefix to use when generating glb file
  61683. * @param options Exporter options
  61684. * @returns Returns an object with a .glb filename as key and data as value
  61685. */
  61686. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  61687. }
  61688. }
  61689. declare module BABYLON.GLTF2.Exporter {
  61690. /**
  61691. * @hidden
  61692. */
  61693. export class _GLTFUtilities {
  61694. /**
  61695. * Creates a buffer view based on the supplied arguments
  61696. * @param bufferIndex index value of the specified buffer
  61697. * @param byteOffset byte offset value
  61698. * @param byteLength byte length of the bufferView
  61699. * @param byteStride byte distance between conequential elements
  61700. * @param name name of the buffer view
  61701. * @returns bufferView for glTF
  61702. */ private static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  61703. /**
  61704. * Creates an accessor based on the supplied arguments
  61705. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  61706. * @param name The name of the accessor
  61707. * @param type The type of the accessor
  61708. * @param componentType The datatype of components in the attribute
  61709. * @param count The number of attributes referenced by this accessor
  61710. * @param byteOffset The offset relative to the start of the bufferView in bytes
  61711. * @param min Minimum value of each component in this attribute
  61712. * @param max Maximum value of each component in this attribute
  61713. * @returns accessor for glTF
  61714. */ private static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  61715. /**
  61716. * Calculates the minimum and maximum values of an array of position floats
  61717. * @param positions Positions array of a mesh
  61718. * @param vertexStart Starting vertex offset to calculate min and max values
  61719. * @param vertexCount Number of vertices to check for min and max values
  61720. * @returns min number array and max number array
  61721. */ private static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  61722. min: number[];
  61723. max: number[];
  61724. };
  61725. /**
  61726. * Converts a new right-handed Vector3
  61727. * @param vector vector3 array
  61728. * @returns right-handed Vector3
  61729. */ private static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  61730. /**
  61731. * Converts a Vector3 to right-handed
  61732. * @param vector Vector3 to convert to right-handed
  61733. */ private static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  61734. /**
  61735. * Converts a three element number array to right-handed
  61736. * @param vector number array to convert to right-handed
  61737. */ private static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  61738. /**
  61739. * Converts a new right-handed Vector3
  61740. * @param vector vector3 array
  61741. * @returns right-handed Vector3
  61742. */ private static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  61743. /**
  61744. * Converts a Vector3 to right-handed
  61745. * @param vector Vector3 to convert to right-handed
  61746. */ private static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  61747. /**
  61748. * Converts a three element number array to right-handed
  61749. * @param vector number array to convert to right-handed
  61750. */ private static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  61751. /**
  61752. * Converts a Vector4 to right-handed
  61753. * @param vector Vector4 to convert to right-handed
  61754. */ private static _GetRightHandedVector4FromRef(vector: Vector4): void;
  61755. /**
  61756. * Converts a Vector4 to right-handed
  61757. * @param vector Vector4 to convert to right-handed
  61758. */ private static _GetRightHandedArray4FromRef(vector: number[]): void;
  61759. /**
  61760. * Converts a Quaternion to right-handed
  61761. * @param quaternion Source quaternion to convert to right-handed
  61762. */ private static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  61763. /**
  61764. * Converts a Quaternion to right-handed
  61765. * @param quaternion Source quaternion to convert to right-handed
  61766. */ private static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void; private static _NormalizeTangentFromRef(tangent: Vector4): void;
  61767. }
  61768. }
  61769. declare module BABYLON.GLTF2.Exporter {
  61770. /**
  61771. * Converts Babylon Scene into glTF 2.0.
  61772. * @hidden
  61773. */
  61774. export class _Exporter {
  61775. /**
  61776. * Stores the glTF to export
  61777. */ glTF: IGLTF;
  61778. /**
  61779. * Stores all generated buffer views, which represents views into the main glTF buffer data
  61780. */ bufferViews: IBufferView[];
  61781. /**
  61782. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  61783. */ accessors: IAccessor[];
  61784. /**
  61785. * Stores all the generated nodes, which contains transform and/or mesh information per node
  61786. */
  61787. private _nodes;
  61788. /**
  61789. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  61790. */
  61791. private _scenes;
  61792. /**
  61793. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  61794. */
  61795. private _meshes;
  61796. /**
  61797. * Stores all the generated material information, which represents the appearance of each primitive
  61798. */ materials: IMaterial[]; materialMap: {
  61799. [materialID: number]: number;
  61800. };
  61801. /**
  61802. * Stores all the generated texture information, which is referenced by glTF materials
  61803. */ textures: ITexture[];
  61804. /**
  61805. * Stores all the generated image information, which is referenced by glTF textures
  61806. */ images: IImage[];
  61807. /**
  61808. * Stores all the texture samplers
  61809. */ samplers: ISampler[];
  61810. /**
  61811. * Stores all the generated animation samplers, which is referenced by glTF animations
  61812. */
  61813. /**
  61814. * Stores the animations for glTF models
  61815. */
  61816. private _animations;
  61817. /**
  61818. * Stores the total amount of bytes stored in the glTF buffer
  61819. */
  61820. private _totalByteLength;
  61821. /**
  61822. * Stores a reference to the Babylon scene containing the source geometry and material information
  61823. */ babylonScene: Scene;
  61824. /**
  61825. * Stores a map of the image data, where the key is the file name and the value
  61826. * is the image data
  61827. */ imageData: {
  61828. [fileName: string]: {
  61829. data: Uint8Array;
  61830. mimeType: ImageMimeType;
  61831. };
  61832. };
  61833. /**
  61834. * Stores a map of the unique id of a node to its index in the node array
  61835. */
  61836. private _nodeMap;
  61837. /**
  61838. * Specifies if the Babylon scene should be converted to right-handed on export
  61839. */ convertToRightHandedSystem: boolean;
  61840. /**
  61841. * Baked animation sample rate
  61842. */
  61843. private _animationSampleRate;
  61844. /**
  61845. * Callback which specifies if a node should be exported or not
  61846. */
  61847. private _shouldExportNode;
  61848. private _localEngine; glTFMaterialExporter: _GLTFMaterialExporter;
  61849. private _extensions;
  61850. private static _ExtensionNames;
  61851. private static _ExtensionFactories;
  61852. 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>>;
  61853. private _forEachExtensions;
  61854. private _extensionsOnExporting;
  61855. /**
  61856. * Load glTF serializer extensions
  61857. */
  61858. private _loadExtensions;
  61859. /**
  61860. * Creates a glTF Exporter instance, which can accept optional exporter options
  61861. * @param babylonScene Babylon scene object
  61862. * @param options Options to modify the behavior of the exporter
  61863. */
  61864. constructor(babylonScene: Scene, options?: IExportOptions);
  61865. /**
  61866. * Registers a glTF exporter extension
  61867. * @param name Name of the extension to export
  61868. * @param factory The factory function that creates the exporter extension
  61869. */
  61870. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  61871. /**
  61872. * Un-registers an exporter extension
  61873. * @param name The name fo the exporter extension
  61874. * @returns A boolean indicating whether the extension has been un-registered
  61875. */
  61876. static UnregisterExtension(name: string): boolean;
  61877. /**
  61878. * Lazy load a local engine with premultiplied alpha set to false
  61879. */ getLocalEngine(): Engine;
  61880. private reorderIndicesBasedOnPrimitiveMode;
  61881. /**
  61882. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  61883. * clock-wise during export to glTF
  61884. * @param submesh BabylonJS submesh
  61885. * @param primitiveMode Primitive mode of the mesh
  61886. * @param sideOrientation the winding order of the submesh
  61887. * @param vertexBufferKind The type of vertex attribute
  61888. * @param meshAttributeArray The vertex attribute data
  61889. * @param byteOffset The offset to the binary data
  61890. * @param binaryWriter The binary data for the glTF file
  61891. */
  61892. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  61893. /**
  61894. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  61895. * clock-wise during export to glTF
  61896. * @param submesh BabylonJS submesh
  61897. * @param primitiveMode Primitive mode of the mesh
  61898. * @param sideOrientation the winding order of the submesh
  61899. * @param vertexBufferKind The type of vertex attribute
  61900. * @param meshAttributeArray The vertex attribute data
  61901. * @param byteOffset The offset to the binary data
  61902. * @param binaryWriter The binary data for the glTF file
  61903. */
  61904. private reorderTriangleFillMode;
  61905. /**
  61906. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  61907. * clock-wise during export to glTF
  61908. * @param submesh BabylonJS submesh
  61909. * @param primitiveMode Primitive mode of the mesh
  61910. * @param sideOrientation the winding order of the submesh
  61911. * @param vertexBufferKind The type of vertex attribute
  61912. * @param meshAttributeArray The vertex attribute data
  61913. * @param byteOffset The offset to the binary data
  61914. * @param binaryWriter The binary data for the glTF file
  61915. */
  61916. private reorderTriangleStripDrawMode;
  61917. /**
  61918. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  61919. * clock-wise during export to glTF
  61920. * @param submesh BabylonJS submesh
  61921. * @param primitiveMode Primitive mode of the mesh
  61922. * @param sideOrientation the winding order of the submesh
  61923. * @param vertexBufferKind The type of vertex attribute
  61924. * @param meshAttributeArray The vertex attribute data
  61925. * @param byteOffset The offset to the binary data
  61926. * @param binaryWriter The binary data for the glTF file
  61927. */
  61928. private reorderTriangleFanMode;
  61929. /**
  61930. * Writes the vertex attribute data to binary
  61931. * @param vertices The vertices to write to the binary writer
  61932. * @param byteOffset The offset into the binary writer to overwrite binary data
  61933. * @param vertexAttributeKind The vertex attribute type
  61934. * @param meshAttributeArray The vertex attribute data
  61935. * @param binaryWriter The writer containing the binary data
  61936. */
  61937. private writeVertexAttributeData;
  61938. /**
  61939. * Writes mesh attribute data to a data buffer
  61940. * Returns the bytelength of the data
  61941. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  61942. * @param meshAttributeArray Array containing the attribute data
  61943. * @param binaryWriter The buffer to write the binary data to
  61944. * @param indices Used to specify the order of the vertex data
  61945. */
  61946. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  61947. /**
  61948. * Generates glTF json data
  61949. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  61950. * @param glTFPrefix Text to use when prefixing a glTF file
  61951. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  61952. * @returns json data as string
  61953. */
  61954. private generateJSON;
  61955. /**
  61956. * Generates data for .gltf and .bin files based on the glTF prefix string
  61957. * @param glTFPrefix Text to use when prefixing a glTF file
  61958. * @returns GLTFData with glTF file data
  61959. */ generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  61960. /**
  61961. * Creates a binary buffer for glTF
  61962. * @returns array buffer for binary data
  61963. */
  61964. private _generateBinaryAsync;
  61965. /**
  61966. * Pads the number to a multiple of 4
  61967. * @param num number to pad
  61968. * @returns padded number
  61969. */
  61970. private _getPadding;
  61971. /**
  61972. * Generates a glb file from the json and binary data
  61973. * Returns an object with the glb file name as the key and data as the value
  61974. * @param glTFPrefix
  61975. * @returns object with glb filename as key and data as value
  61976. */ generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  61977. /**
  61978. * Sets the TRS for each node
  61979. * @param node glTF Node for storing the transformation data
  61980. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  61981. */
  61982. private setNodeTransformation;
  61983. private getVertexBufferFromMesh;
  61984. /**
  61985. * Creates a bufferview based on the vertices type for the Babylon mesh
  61986. * @param kind Indicates the type of vertices data
  61987. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  61988. * @param binaryWriter The buffer to write the bufferview data to
  61989. */
  61990. private createBufferViewKind;
  61991. /**
  61992. * The primitive mode of the Babylon mesh
  61993. * @param babylonMesh The BabylonJS mesh
  61994. */
  61995. private getMeshPrimitiveMode;
  61996. /**
  61997. * Sets the primitive mode of the glTF mesh primitive
  61998. * @param meshPrimitive glTF mesh primitive
  61999. * @param primitiveMode The primitive mode
  62000. */
  62001. private setPrimitiveMode;
  62002. /**
  62003. * Sets the vertex attribute accessor based of the glTF mesh primitive
  62004. * @param meshPrimitive glTF mesh primitive
  62005. * @param attributeKind vertex attribute
  62006. * @returns boolean specifying if uv coordinates are present
  62007. */
  62008. private setAttributeKind;
  62009. /**
  62010. * Sets data for the primitive attributes of each submesh
  62011. * @param mesh glTF Mesh object to store the primitive attribute information
  62012. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  62013. * @param binaryWriter Buffer to write the attribute data to
  62014. */
  62015. private setPrimitiveAttributesAsync;
  62016. /**
  62017. * Creates a glTF scene based on the array of meshes
  62018. * Returns the the total byte offset
  62019. * @param babylonScene Babylon scene to get the mesh data from
  62020. * @param binaryWriter Buffer to write binary data to
  62021. */
  62022. private createSceneAsync;
  62023. /**
  62024. * Creates a mapping of Node unique id to node index and handles animations
  62025. * @param babylonScene Babylon Scene
  62026. * @param nodes Babylon transform nodes
  62027. * @param shouldExportNode Callback specifying if a transform node should be exported
  62028. * @param binaryWriter Buffer to write binary data to
  62029. * @returns Node mapping of unique id to index
  62030. */
  62031. private createNodeMapAndAnimationsAsync;
  62032. /**
  62033. * Creates a glTF node from a Babylon mesh
  62034. * @param babylonMesh Source Babylon mesh
  62035. * @param binaryWriter Buffer for storing geometry data
  62036. * @returns glTF node
  62037. */
  62038. private createNodeAsync;
  62039. }
  62040. /**
  62041. * @hidden
  62042. *
  62043. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  62044. */
  62045. export class _BinaryWriter {
  62046. /**
  62047. * Array buffer which stores all binary data
  62048. */
  62049. private _arrayBuffer;
  62050. /**
  62051. * View of the array buffer
  62052. */
  62053. private _dataView;
  62054. /**
  62055. * byte offset of data in array buffer
  62056. */
  62057. private _byteOffset;
  62058. /**
  62059. * Initialize binary writer with an initial byte length
  62060. * @param byteLength Initial byte length of the array buffer
  62061. */
  62062. constructor(byteLength: number);
  62063. /**
  62064. * Resize the array buffer to the specified byte length
  62065. * @param byteLength
  62066. */
  62067. private resizeBuffer;
  62068. /**
  62069. * Get an array buffer with the length of the byte offset
  62070. * @returns ArrayBuffer resized to the byte offset
  62071. */
  62072. getArrayBuffer(): ArrayBuffer;
  62073. /**
  62074. * Get the byte offset of the array buffer
  62075. * @returns byte offset
  62076. */
  62077. getByteOffset(): number;
  62078. /**
  62079. * Stores an UInt8 in the array buffer
  62080. * @param entry
  62081. * @param byteOffset If defined, specifies where to set the value as an offset.
  62082. */
  62083. setUInt8(entry: number, byteOffset?: number): void;
  62084. /**
  62085. * Gets an UInt32 in the array buffer
  62086. * @param entry
  62087. * @param byteOffset If defined, specifies where to set the value as an offset.
  62088. */
  62089. getUInt32(byteOffset: number): number;
  62090. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  62091. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  62092. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  62093. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  62094. /**
  62095. * Stores a Float32 in the array buffer
  62096. * @param entry
  62097. */
  62098. setFloat32(entry: number, byteOffset?: number): void;
  62099. /**
  62100. * Stores an UInt32 in the array buffer
  62101. * @param entry
  62102. * @param byteOffset If defined, specifies where to set the value as an offset.
  62103. */
  62104. setUInt32(entry: number, byteOffset?: number): void;
  62105. }
  62106. }
  62107. declare module BABYLON.GLTF2.Exporter {
  62108. /**
  62109. * @hidden
  62110. * Interface to store animation data.
  62111. */
  62112. export interface _IAnimationData {
  62113. /**
  62114. * Keyframe data.
  62115. */
  62116. inputs: number[];
  62117. /**
  62118. * Value data.
  62119. */
  62120. outputs: number[][];
  62121. /**
  62122. * Animation interpolation data.
  62123. */
  62124. samplerInterpolation: AnimationSamplerInterpolation;
  62125. /**
  62126. * Minimum keyframe value.
  62127. */
  62128. inputsMin: number;
  62129. /**
  62130. * Maximum keyframe value.
  62131. */
  62132. inputsMax: number;
  62133. }
  62134. /**
  62135. * @hidden
  62136. */
  62137. export interface _IAnimationInfo {
  62138. /**
  62139. * The target channel for the animation
  62140. */
  62141. animationChannelTargetPath: AnimationChannelTargetPath;
  62142. /**
  62143. * The glTF accessor type for the data.
  62144. */
  62145. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  62146. /**
  62147. * Specifies if quaternions should be used.
  62148. */
  62149. useQuaternion: boolean;
  62150. }
  62151. /**
  62152. * @hidden
  62153. * Utility class for generating glTF animation data from BabylonJS.
  62154. */
  62155. export class _GLTFAnimation {
  62156. /**
  62157. * @ignore
  62158. *
  62159. * Creates glTF channel animation from BabylonJS animation.
  62160. * @param babylonTransformNode - BabylonJS mesh.
  62161. * @param animation - animation.
  62162. * @param animationChannelTargetPath - The target animation channel.
  62163. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  62164. * @param useQuaternion - Specifies if quaternions are used.
  62165. * @returns nullable IAnimationData
  62166. */ private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  62167. private static _DeduceAnimationInfo;
  62168. /**
  62169. * @ignore
  62170. * Create node animations from the transform node animations
  62171. * @param babylonNode
  62172. * @param runtimeGLTFAnimation
  62173. * @param idleGLTFAnimations
  62174. * @param nodeMap
  62175. * @param nodes
  62176. * @param binaryWriter
  62177. * @param bufferViews
  62178. * @param accessors
  62179. * @param convertToRightHandedSystem
  62180. */ private static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  62181. [key: number]: number;
  62182. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  62183. /**
  62184. * @ignore
  62185. * Create node animations from the animation groups
  62186. * @param babylonScene
  62187. * @param glTFAnimations
  62188. * @param nodeMap
  62189. * @param nodes
  62190. * @param binaryWriter
  62191. * @param bufferViews
  62192. * @param accessors
  62193. * @param convertToRightHandedSystem
  62194. */ private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  62195. [key: number]: number;
  62196. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  62197. private static AddAnimation;
  62198. /**
  62199. * Create a baked animation
  62200. * @param babylonTransformNode BabylonJS mesh
  62201. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  62202. * @param animationChannelTargetPath animation target channel
  62203. * @param minFrame minimum animation frame
  62204. * @param maxFrame maximum animation frame
  62205. * @param fps frames per second of the animation
  62206. * @param inputs input key frames of the animation
  62207. * @param outputs output key frame data of the animation
  62208. * @param convertToRightHandedSystem converts the values to right-handed
  62209. * @param useQuaternion specifies if quaternions should be used
  62210. */
  62211. private static _CreateBakedAnimation;
  62212. private static _ConvertFactorToVector3OrQuaternion;
  62213. private static _SetInterpolatedValue;
  62214. /**
  62215. * Creates linear animation from the animation key frames
  62216. * @param babylonTransformNode BabylonJS mesh
  62217. * @param animation BabylonJS animation
  62218. * @param animationChannelTargetPath The target animation channel
  62219. * @param frameDelta The difference between the last and first frame of the animation
  62220. * @param inputs Array to store the key frame times
  62221. * @param outputs Array to store the key frame data
  62222. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  62223. * @param useQuaternion Specifies if quaternions are used in the animation
  62224. */
  62225. private static _CreateLinearOrStepAnimation;
  62226. /**
  62227. * Creates cubic spline animation from the animation key frames
  62228. * @param babylonTransformNode BabylonJS mesh
  62229. * @param animation BabylonJS animation
  62230. * @param animationChannelTargetPath The target animation channel
  62231. * @param frameDelta The difference between the last and first frame of the animation
  62232. * @param inputs Array to store the key frame times
  62233. * @param outputs Array to store the key frame data
  62234. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  62235. * @param useQuaternion Specifies if quaternions are used in the animation
  62236. */
  62237. private static _CreateCubicSplineAnimation;
  62238. private static _GetBasePositionRotationOrScale;
  62239. /**
  62240. * Adds a key frame value
  62241. * @param keyFrame
  62242. * @param animation
  62243. * @param outputs
  62244. * @param animationChannelTargetPath
  62245. * @param basePositionRotationOrScale
  62246. * @param convertToRightHandedSystem
  62247. * @param useQuaternion
  62248. */
  62249. private static _AddKeyframeValue;
  62250. /**
  62251. * Determine the interpolation based on the key frames
  62252. * @param keyFrames
  62253. * @param animationChannelTargetPath
  62254. * @param useQuaternion
  62255. */
  62256. private static _DeduceInterpolation;
  62257. /**
  62258. * Adds an input tangent or output tangent to the output data
  62259. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  62260. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  62261. * @param outputs The animation data by keyframe
  62262. * @param animationChannelTargetPath The target animation channel
  62263. * @param interpolation The interpolation type
  62264. * @param keyFrame The key frame with the animation data
  62265. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  62266. * @param useQuaternion Specifies if quaternions are used
  62267. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  62268. */
  62269. private static AddSplineTangent;
  62270. /**
  62271. * Get the minimum and maximum key frames' frame values
  62272. * @param keyFrames animation key frames
  62273. * @returns the minimum and maximum key frame value
  62274. */
  62275. private static calculateMinMaxKeyFrames;
  62276. }
  62277. }
  62278. declare module BABYLON.GLTF2.Exporter {
  62279. /** @hidden */
  62280. export var textureTransformPixelShader: {
  62281. name: string;
  62282. shader: string;
  62283. };
  62284. }
  62285. declare module BABYLON.GLTF2.Exporter.Extensions {
  62286. /**
  62287. * @hidden
  62288. */
  62289. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  62290. /** Name of this extension */
  62291. readonly name: string;
  62292. /** Defines whether this extension is enabled */
  62293. enabled: boolean;
  62294. /** Defines whether this extension is required */
  62295. required: boolean;
  62296. /** Reference to the glTF exporter */
  62297. private _exporter;
  62298. constructor(exporter: _Exporter);
  62299. dispose(): void;
  62300. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  62301. /**
  62302. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  62303. * @param babylonTexture
  62304. * @param offset
  62305. * @param rotation
  62306. * @param scale
  62307. * @param scene
  62308. */
  62309. textureTransformTextureAsync(babylonTexture: Texture, offset: Vector2, rotation: number, scale: Vector2, scene: Scene): Promise<BaseTexture>;
  62310. }
  62311. }
  62312. declare module BABYLON.GLTF2.Exporter.Extensions {
  62313. /**
  62314. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  62315. */
  62316. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  62317. /** The name of this extension. */
  62318. readonly name: string;
  62319. /** Defines whether this extension is enabled. */
  62320. enabled: boolean;
  62321. /** Defines whether this extension is required */
  62322. required: boolean;
  62323. /** Reference to the glTF exporter */
  62324. private _exporter;
  62325. private _lights;
  62326. /** @hidden */
  62327. constructor(exporter: _Exporter);
  62328. /** @hidden */
  62329. dispose(): void;
  62330. /** @hidden */
  62331. onExporting(): void;
  62332. /**
  62333. * Define this method to modify the default behavior when exporting a node
  62334. * @param context The context when exporting the node
  62335. * @param node glTF node
  62336. * @param babylonNode BabylonJS node
  62337. * @returns nullable INode promise
  62338. */
  62339. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  62340. }
  62341. }
  62342. declare module BABYLON {
  62343. /**
  62344. * Class for generating STL data from a Babylon scene.
  62345. */
  62346. export class STLExport {
  62347. /**
  62348. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  62349. * @param meshes list defines the mesh to serialize
  62350. * @param download triggers the automatic download of the file.
  62351. * @param fileName changes the downloads fileName.
  62352. * @param binary changes the STL to a binary type.
  62353. * @param isLittleEndian toggle for binary type exporter.
  62354. * @returns the STL as UTF8 string
  62355. */
  62356. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  62357. }
  62358. }
  62359. /**
  62360. * @ignoreChildren
  62361. * @ignore
  62362. */
  62363. declare module "babylonjs-gltf2interface" {
  62364. export = BABYLON.GLTF2;
  62365. }
  62366. /**
  62367. * Module for glTF 2.0 Interface
  62368. * @ignoreChildren
  62369. * @ignore
  62370. */
  62371. declare module BABYLON.GLTF2 {
  62372. /**
  62373. * The datatype of the components in the attribute
  62374. */
  62375. const enum AccessorComponentType {
  62376. /**
  62377. * Byte
  62378. */
  62379. BYTE = 5120,
  62380. /**
  62381. * Unsigned Byte
  62382. */
  62383. UNSIGNED_BYTE = 5121,
  62384. /**
  62385. * Short
  62386. */
  62387. SHORT = 5122,
  62388. /**
  62389. * Unsigned Short
  62390. */
  62391. UNSIGNED_SHORT = 5123,
  62392. /**
  62393. * Unsigned Int
  62394. */
  62395. UNSIGNED_INT = 5125,
  62396. /**
  62397. * Float
  62398. */
  62399. FLOAT = 5126,
  62400. }
  62401. /**
  62402. * Specifies if the attirbute is a scalar, vector, or matrix
  62403. */
  62404. const enum AccessorType {
  62405. /**
  62406. * Scalar
  62407. */
  62408. SCALAR = "SCALAR",
  62409. /**
  62410. * Vector2
  62411. */
  62412. VEC2 = "VEC2",
  62413. /**
  62414. * Vector3
  62415. */
  62416. VEC3 = "VEC3",
  62417. /**
  62418. * Vector4
  62419. */
  62420. VEC4 = "VEC4",
  62421. /**
  62422. * Matrix2x2
  62423. */
  62424. MAT2 = "MAT2",
  62425. /**
  62426. * Matrix3x3
  62427. */
  62428. MAT3 = "MAT3",
  62429. /**
  62430. * Matrix4x4
  62431. */
  62432. MAT4 = "MAT4",
  62433. }
  62434. /**
  62435. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  62436. */
  62437. const enum AnimationChannelTargetPath {
  62438. /**
  62439. * Translation
  62440. */
  62441. TRANSLATION = "translation",
  62442. /**
  62443. * Rotation
  62444. */
  62445. ROTATION = "rotation",
  62446. /**
  62447. * Scale
  62448. */
  62449. SCALE = "scale",
  62450. /**
  62451. * Weights
  62452. */
  62453. WEIGHTS = "weights",
  62454. }
  62455. /**
  62456. * Interpolation algorithm
  62457. */
  62458. const enum AnimationSamplerInterpolation {
  62459. /**
  62460. * The animated values are linearly interpolated between keyframes
  62461. */
  62462. LINEAR = "LINEAR",
  62463. /**
  62464. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  62465. */
  62466. STEP = "STEP",
  62467. /**
  62468. * The animation's interpolation is computed using a cubic spline with specified tangents
  62469. */
  62470. CUBICSPLINE = "CUBICSPLINE",
  62471. }
  62472. /**
  62473. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  62474. */
  62475. const enum CameraType {
  62476. /**
  62477. * A perspective camera containing properties to create a perspective projection matrix
  62478. */
  62479. PERSPECTIVE = "perspective",
  62480. /**
  62481. * An orthographic camera containing properties to create an orthographic projection matrix
  62482. */
  62483. ORTHOGRAPHIC = "orthographic",
  62484. }
  62485. /**
  62486. * The mime-type of the image
  62487. */
  62488. const enum ImageMimeType {
  62489. /**
  62490. * JPEG Mime-type
  62491. */
  62492. JPEG = "image/jpeg",
  62493. /**
  62494. * PNG Mime-type
  62495. */
  62496. PNG = "image/png",
  62497. }
  62498. /**
  62499. * The alpha rendering mode of the material
  62500. */
  62501. const enum MaterialAlphaMode {
  62502. /**
  62503. * The alpha value is ignored and the rendered output is fully opaque
  62504. */
  62505. OPAQUE = "OPAQUE",
  62506. /**
  62507. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  62508. */
  62509. MASK = "MASK",
  62510. /**
  62511. * 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)
  62512. */
  62513. BLEND = "BLEND",
  62514. }
  62515. /**
  62516. * The type of the primitives to render
  62517. */
  62518. const enum MeshPrimitiveMode {
  62519. /**
  62520. * Points
  62521. */
  62522. POINTS = 0,
  62523. /**
  62524. * Lines
  62525. */
  62526. LINES = 1,
  62527. /**
  62528. * Line Loop
  62529. */
  62530. LINE_LOOP = 2,
  62531. /**
  62532. * Line Strip
  62533. */
  62534. LINE_STRIP = 3,
  62535. /**
  62536. * Triangles
  62537. */
  62538. TRIANGLES = 4,
  62539. /**
  62540. * Triangle Strip
  62541. */
  62542. TRIANGLE_STRIP = 5,
  62543. /**
  62544. * Triangle Fan
  62545. */
  62546. TRIANGLE_FAN = 6,
  62547. }
  62548. /**
  62549. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  62550. */
  62551. const enum TextureMagFilter {
  62552. /**
  62553. * Nearest
  62554. */
  62555. NEAREST = 9728,
  62556. /**
  62557. * Linear
  62558. */
  62559. LINEAR = 9729,
  62560. }
  62561. /**
  62562. * Minification filter. All valid values correspond to WebGL enums
  62563. */
  62564. const enum TextureMinFilter {
  62565. /**
  62566. * Nearest
  62567. */
  62568. NEAREST = 9728,
  62569. /**
  62570. * Linear
  62571. */
  62572. LINEAR = 9729,
  62573. /**
  62574. * Nearest Mip-Map Nearest
  62575. */
  62576. NEAREST_MIPMAP_NEAREST = 9984,
  62577. /**
  62578. * Linear Mipmap Nearest
  62579. */
  62580. LINEAR_MIPMAP_NEAREST = 9985,
  62581. /**
  62582. * Nearest Mipmap Linear
  62583. */
  62584. NEAREST_MIPMAP_LINEAR = 9986,
  62585. /**
  62586. * Linear Mipmap Linear
  62587. */
  62588. LINEAR_MIPMAP_LINEAR = 9987,
  62589. }
  62590. /**
  62591. * S (U) wrapping mode. All valid values correspond to WebGL enums
  62592. */
  62593. const enum TextureWrapMode {
  62594. /**
  62595. * Clamp to Edge
  62596. */
  62597. CLAMP_TO_EDGE = 33071,
  62598. /**
  62599. * Mirrored Repeat
  62600. */
  62601. MIRRORED_REPEAT = 33648,
  62602. /**
  62603. * Repeat
  62604. */
  62605. REPEAT = 10497,
  62606. }
  62607. /**
  62608. * glTF Property
  62609. */
  62610. interface IProperty {
  62611. /**
  62612. * Dictionary object with extension-specific objects
  62613. */
  62614. extensions?: {
  62615. [key: string]: any;
  62616. };
  62617. /**
  62618. * Application-Specific data
  62619. */
  62620. extras?: any;
  62621. }
  62622. /**
  62623. * glTF Child of Root Property
  62624. */
  62625. interface IChildRootProperty extends IProperty {
  62626. /**
  62627. * The user-defined name of this object
  62628. */
  62629. name?: string;
  62630. }
  62631. /**
  62632. * Indices of those attributes that deviate from their initialization value
  62633. */
  62634. interface IAccessorSparseIndices extends IProperty {
  62635. /**
  62636. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  62637. */
  62638. bufferView: number;
  62639. /**
  62640. * The offset relative to the start of the bufferView in bytes. Must be aligned
  62641. */
  62642. byteOffset?: number;
  62643. /**
  62644. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  62645. */
  62646. componentType: AccessorComponentType;
  62647. }
  62648. /**
  62649. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  62650. */
  62651. interface IAccessorSparseValues extends IProperty {
  62652. /**
  62653. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  62654. */
  62655. bufferView: number;
  62656. /**
  62657. * The offset relative to the start of the bufferView in bytes. Must be aligned
  62658. */
  62659. byteOffset?: number;
  62660. }
  62661. /**
  62662. * Sparse storage of attributes that deviate from their initialization value
  62663. */
  62664. interface IAccessorSparse extends IProperty {
  62665. /**
  62666. * The number of attributes encoded in this sparse accessor
  62667. */
  62668. count: number;
  62669. /**
  62670. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  62671. */
  62672. indices: IAccessorSparseIndices;
  62673. /**
  62674. * 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
  62675. */
  62676. values: IAccessorSparseValues;
  62677. }
  62678. /**
  62679. * 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
  62680. */
  62681. interface IAccessor extends IChildRootProperty {
  62682. /**
  62683. * The index of the bufferview
  62684. */
  62685. bufferView?: number;
  62686. /**
  62687. * The offset relative to the start of the bufferView in bytes
  62688. */
  62689. byteOffset?: number;
  62690. /**
  62691. * The datatype of components in the attribute
  62692. */
  62693. componentType: AccessorComponentType;
  62694. /**
  62695. * Specifies whether integer data values should be normalized
  62696. */
  62697. normalized?: boolean;
  62698. /**
  62699. * The number of attributes referenced by this accessor
  62700. */
  62701. count: number;
  62702. /**
  62703. * Specifies if the attribute is a scalar, vector, or matrix
  62704. */
  62705. type: AccessorType;
  62706. /**
  62707. * Maximum value of each component in this attribute
  62708. */
  62709. max?: number[];
  62710. /**
  62711. * Minimum value of each component in this attribute
  62712. */
  62713. min?: number[];
  62714. /**
  62715. * Sparse storage of attributes that deviate from their initialization value
  62716. */
  62717. sparse?: IAccessorSparse;
  62718. }
  62719. /**
  62720. * Targets an animation's sampler at a node's property
  62721. */
  62722. interface IAnimationChannel extends IProperty {
  62723. /**
  62724. * The index of a sampler in this animation used to compute the value for the target
  62725. */
  62726. sampler: number;
  62727. /**
  62728. * The index of the node and TRS property to target
  62729. */
  62730. target: IAnimationChannelTarget;
  62731. }
  62732. /**
  62733. * The index of the node and TRS property that an animation channel targets
  62734. */
  62735. interface IAnimationChannelTarget extends IProperty {
  62736. /**
  62737. * The index of the node to target
  62738. */
  62739. node: number;
  62740. /**
  62741. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  62742. */
  62743. path: AnimationChannelTargetPath;
  62744. }
  62745. /**
  62746. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  62747. */
  62748. interface IAnimationSampler extends IProperty {
  62749. /**
  62750. * The index of an accessor containing keyframe input values, e.g., time
  62751. */
  62752. input: number;
  62753. /**
  62754. * Interpolation algorithm
  62755. */
  62756. interpolation?: AnimationSamplerInterpolation;
  62757. /**
  62758. * The index of an accessor, containing keyframe output values
  62759. */
  62760. output: number;
  62761. }
  62762. /**
  62763. * A keyframe animation
  62764. */
  62765. interface IAnimation extends IChildRootProperty {
  62766. /**
  62767. * An array of channels, each of which targets an animation's sampler at a node's property
  62768. */
  62769. channels: IAnimationChannel[];
  62770. /**
  62771. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  62772. */
  62773. samplers: IAnimationSampler[];
  62774. }
  62775. /**
  62776. * Metadata about the glTF asset
  62777. */
  62778. interface IAsset extends IChildRootProperty {
  62779. /**
  62780. * A copyright message suitable for display to credit the content creator
  62781. */
  62782. copyright?: string;
  62783. /**
  62784. * Tool that generated this glTF model. Useful for debugging
  62785. */
  62786. generator?: string;
  62787. /**
  62788. * The glTF version that this asset targets
  62789. */
  62790. version: string;
  62791. /**
  62792. * The minimum glTF version that this asset targets
  62793. */
  62794. minVersion?: string;
  62795. }
  62796. /**
  62797. * A buffer points to binary geometry, animation, or skins
  62798. */
  62799. interface IBuffer extends IChildRootProperty {
  62800. /**
  62801. * 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
  62802. */
  62803. uri?: string;
  62804. /**
  62805. * The length of the buffer in bytes
  62806. */
  62807. byteLength: number;
  62808. }
  62809. /**
  62810. * A view into a buffer generally representing a subset of the buffer
  62811. */
  62812. interface IBufferView extends IChildRootProperty {
  62813. /**
  62814. * The index of the buffer
  62815. */
  62816. buffer: number;
  62817. /**
  62818. * The offset into the buffer in bytes
  62819. */
  62820. byteOffset?: number;
  62821. /**
  62822. * The lenth of the bufferView in bytes
  62823. */
  62824. byteLength: number;
  62825. /**
  62826. * The stride, in bytes
  62827. */
  62828. byteStride?: number;
  62829. }
  62830. /**
  62831. * An orthographic camera containing properties to create an orthographic projection matrix
  62832. */
  62833. interface ICameraOrthographic extends IProperty {
  62834. /**
  62835. * The floating-point horizontal magnification of the view. Must not be zero
  62836. */
  62837. xmag: number;
  62838. /**
  62839. * The floating-point vertical magnification of the view. Must not be zero
  62840. */
  62841. ymag: number;
  62842. /**
  62843. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  62844. */
  62845. zfar: number;
  62846. /**
  62847. * The floating-point distance to the near clipping plane
  62848. */
  62849. znear: number;
  62850. }
  62851. /**
  62852. * A perspective camera containing properties to create a perspective projection matrix
  62853. */
  62854. interface ICameraPerspective extends IProperty {
  62855. /**
  62856. * The floating-point aspect ratio of the field of view
  62857. */
  62858. aspectRatio?: number;
  62859. /**
  62860. * The floating-point vertical field of view in radians
  62861. */
  62862. yfov: number;
  62863. /**
  62864. * The floating-point distance to the far clipping plane
  62865. */
  62866. zfar?: number;
  62867. /**
  62868. * The floating-point distance to the near clipping plane
  62869. */
  62870. znear: number;
  62871. }
  62872. /**
  62873. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  62874. */
  62875. interface ICamera extends IChildRootProperty {
  62876. /**
  62877. * An orthographic camera containing properties to create an orthographic projection matrix
  62878. */
  62879. orthographic?: ICameraOrthographic;
  62880. /**
  62881. * A perspective camera containing properties to create a perspective projection matrix
  62882. */
  62883. perspective?: ICameraPerspective;
  62884. /**
  62885. * Specifies if the camera uses a perspective or orthographic projection
  62886. */
  62887. type: CameraType;
  62888. }
  62889. /**
  62890. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  62891. */
  62892. interface IImage extends IChildRootProperty {
  62893. /**
  62894. * 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
  62895. */
  62896. uri?: string;
  62897. /**
  62898. * The image's MIME type
  62899. */
  62900. mimeType?: ImageMimeType;
  62901. /**
  62902. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  62903. */
  62904. bufferView?: number;
  62905. }
  62906. /**
  62907. * Material Normal Texture Info
  62908. */
  62909. interface IMaterialNormalTextureInfo extends ITextureInfo {
  62910. /**
  62911. * The scalar multiplier applied to each normal vector of the normal texture
  62912. */
  62913. scale?: number;
  62914. }
  62915. /**
  62916. * Material Occlusion Texture Info
  62917. */
  62918. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  62919. /**
  62920. * A scalar multiplier controlling the amount of occlusion applied
  62921. */
  62922. strength?: number;
  62923. }
  62924. /**
  62925. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  62926. */
  62927. interface IMaterialPbrMetallicRoughness {
  62928. /**
  62929. * The material's base color factor
  62930. */
  62931. baseColorFactor?: number[];
  62932. /**
  62933. * The base color texture
  62934. */
  62935. baseColorTexture?: ITextureInfo;
  62936. /**
  62937. * The metalness of the material
  62938. */
  62939. metallicFactor?: number;
  62940. /**
  62941. * The roughness of the material
  62942. */
  62943. roughnessFactor?: number;
  62944. /**
  62945. * The metallic-roughness texture
  62946. */
  62947. metallicRoughnessTexture?: ITextureInfo;
  62948. }
  62949. /**
  62950. * The material appearance of a primitive
  62951. */
  62952. interface IMaterial extends IChildRootProperty {
  62953. /**
  62954. * 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
  62955. */
  62956. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  62957. /**
  62958. * The normal map texture
  62959. */
  62960. normalTexture?: IMaterialNormalTextureInfo;
  62961. /**
  62962. * The occlusion map texture
  62963. */
  62964. occlusionTexture?: IMaterialOcclusionTextureInfo;
  62965. /**
  62966. * The emissive map texture
  62967. */
  62968. emissiveTexture?: ITextureInfo;
  62969. /**
  62970. * 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
  62971. */
  62972. emissiveFactor?: number[];
  62973. /**
  62974. * The alpha rendering mode of the material
  62975. */
  62976. alphaMode?: MaterialAlphaMode;
  62977. /**
  62978. * The alpha cutoff value of the material
  62979. */
  62980. alphaCutoff?: number;
  62981. /**
  62982. * Specifies whether the material is double sided
  62983. */
  62984. doubleSided?: boolean;
  62985. }
  62986. /**
  62987. * Geometry to be rendered with the given material
  62988. */
  62989. interface IMeshPrimitive extends IProperty {
  62990. /**
  62991. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  62992. */
  62993. attributes: {
  62994. [name: string]: number;
  62995. };
  62996. /**
  62997. * The index of the accessor that contains the indices
  62998. */
  62999. indices?: number;
  63000. /**
  63001. * The index of the material to apply to this primitive when rendering
  63002. */
  63003. material?: number;
  63004. /**
  63005. * The type of primitives to render. All valid values correspond to WebGL enums
  63006. */
  63007. mode?: MeshPrimitiveMode;
  63008. /**
  63009. * 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
  63010. */
  63011. targets?: {
  63012. [name: string]: number;
  63013. }[];
  63014. }
  63015. /**
  63016. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  63017. */
  63018. interface IMesh extends IChildRootProperty {
  63019. /**
  63020. * An array of primitives, each defining geometry to be rendered with a material
  63021. */
  63022. primitives: IMeshPrimitive[];
  63023. /**
  63024. * Array of weights to be applied to the Morph Targets
  63025. */
  63026. weights?: number[];
  63027. }
  63028. /**
  63029. * A node in the node hierarchy
  63030. */
  63031. interface INode extends IChildRootProperty {
  63032. /**
  63033. * The index of the camera referenced by this node
  63034. */
  63035. camera?: number;
  63036. /**
  63037. * The indices of this node's children
  63038. */
  63039. children?: number[];
  63040. /**
  63041. * The index of the skin referenced by this node
  63042. */
  63043. skin?: number;
  63044. /**
  63045. * A floating-point 4x4 transformation matrix stored in column-major order
  63046. */
  63047. matrix?: number[];
  63048. /**
  63049. * The index of the mesh in this node
  63050. */
  63051. mesh?: number;
  63052. /**
  63053. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  63054. */
  63055. rotation?: number[];
  63056. /**
  63057. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  63058. */
  63059. scale?: number[];
  63060. /**
  63061. * The node's translation along the x, y, and z axes
  63062. */
  63063. translation?: number[];
  63064. /**
  63065. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  63066. */
  63067. weights?: number[];
  63068. }
  63069. /**
  63070. * Texture sampler properties for filtering and wrapping modes
  63071. */
  63072. interface ISampler extends IChildRootProperty {
  63073. /**
  63074. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  63075. */
  63076. magFilter?: TextureMagFilter;
  63077. /**
  63078. * Minification filter. All valid values correspond to WebGL enums
  63079. */
  63080. minFilter?: TextureMinFilter;
  63081. /**
  63082. * S (U) wrapping mode. All valid values correspond to WebGL enums
  63083. */
  63084. wrapS?: TextureWrapMode;
  63085. /**
  63086. * T (V) wrapping mode. All valid values correspond to WebGL enums
  63087. */
  63088. wrapT?: TextureWrapMode;
  63089. }
  63090. /**
  63091. * The root nodes of a scene
  63092. */
  63093. interface IScene extends IChildRootProperty {
  63094. /**
  63095. * The indices of each root node
  63096. */
  63097. nodes: number[];
  63098. }
  63099. /**
  63100. * Joints and matrices defining a skin
  63101. */
  63102. interface ISkin extends IChildRootProperty {
  63103. /**
  63104. * 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
  63105. */
  63106. inverseBindMatrices?: number;
  63107. /**
  63108. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  63109. */
  63110. skeleton?: number;
  63111. /**
  63112. * 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)
  63113. */
  63114. joints: number[];
  63115. }
  63116. /**
  63117. * A texture and its sampler
  63118. */
  63119. interface ITexture extends IChildRootProperty {
  63120. /**
  63121. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  63122. */
  63123. sampler?: number;
  63124. /**
  63125. * The index of the image used by this texture
  63126. */
  63127. source: number;
  63128. }
  63129. /**
  63130. * Reference to a texture
  63131. */
  63132. interface ITextureInfo extends IProperty {
  63133. /**
  63134. * The index of the texture
  63135. */
  63136. index: number;
  63137. /**
  63138. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  63139. */
  63140. texCoord?: number;
  63141. }
  63142. /**
  63143. * The root object for a glTF asset
  63144. */
  63145. interface IGLTF extends IProperty {
  63146. /**
  63147. * An array of accessors. An accessor is a typed view into a bufferView
  63148. */
  63149. accessors?: IAccessor[];
  63150. /**
  63151. * An array of keyframe animations
  63152. */
  63153. animations?: IAnimation[];
  63154. /**
  63155. * Metadata about the glTF asset
  63156. */
  63157. asset: IAsset;
  63158. /**
  63159. * An array of buffers. A buffer points to binary geometry, animation, or skins
  63160. */
  63161. buffers?: IBuffer[];
  63162. /**
  63163. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  63164. */
  63165. bufferViews?: IBufferView[];
  63166. /**
  63167. * An array of cameras
  63168. */
  63169. cameras?: ICamera[];
  63170. /**
  63171. * Names of glTF extensions used somewhere in this asset
  63172. */
  63173. extensionsUsed?: string[];
  63174. /**
  63175. * Names of glTF extensions required to properly load this asset
  63176. */
  63177. extensionsRequired?: string[];
  63178. /**
  63179. * An array of images. An image defines data used to create a texture
  63180. */
  63181. images?: IImage[];
  63182. /**
  63183. * An array of materials. A material defines the appearance of a primitive
  63184. */
  63185. materials?: IMaterial[];
  63186. /**
  63187. * An array of meshes. A mesh is a set of primitives to be rendered
  63188. */
  63189. meshes?: IMesh[];
  63190. /**
  63191. * An array of nodes
  63192. */
  63193. nodes?: INode[];
  63194. /**
  63195. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  63196. */
  63197. samplers?: ISampler[];
  63198. /**
  63199. * The index of the default scene
  63200. */
  63201. scene?: number;
  63202. /**
  63203. * An array of scenes
  63204. */
  63205. scenes?: IScene[];
  63206. /**
  63207. * An array of skins. A skin is defined by joints and matrices
  63208. */
  63209. skins?: ISkin[];
  63210. /**
  63211. * An array of textures
  63212. */
  63213. textures?: ITexture[];
  63214. }
  63215. /**
  63216. * Interface for glTF validation results
  63217. */
  63218. interface IGLTFValidationResults {
  63219. info: {
  63220. generator: string;
  63221. hasAnimations: boolean;
  63222. hasDefaultScene: boolean;
  63223. hasMaterials: boolean;
  63224. hasMorphTargets: boolean;
  63225. hasSkins: boolean;
  63226. hasTextures: boolean;
  63227. maxAttributesUsed: number;
  63228. primitivesCount: number
  63229. };
  63230. issues: {
  63231. messages: Array<string>;
  63232. numErrors: number;
  63233. numHints: number;
  63234. numInfos: number;
  63235. numWarnings: number;
  63236. truncated: boolean
  63237. };
  63238. mimeType: string;
  63239. uri: string;
  63240. validatedAt: string;
  63241. validatorVersion: string;
  63242. }
  63243. /**
  63244. * Interface for glTF validation options
  63245. */
  63246. interface IGLTFValidationOptions {
  63247. uri?: string;
  63248. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  63249. validateAccessorData?: boolean;
  63250. maxIssues?: number;
  63251. ignoredIssues?: Array<string>;
  63252. severityOverrides?: Object;
  63253. }
  63254. /**
  63255. * glTF validator object Tyyings
  63256. */
  63257. interface IGLTFValidatorTypings {
  63258. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  63259. }
  63260. }
  63261. /**
  63262. * Interface for glTF validation results
  63263. */
  63264. interface IGLTFValidationResults {
  63265. info: {
  63266. generator: string;
  63267. hasAnimations: boolean;
  63268. hasDefaultScene: boolean;
  63269. hasMaterials: boolean;
  63270. hasMorphTargets: boolean;
  63271. hasSkins: boolean;
  63272. hasTextures: boolean;
  63273. maxAttributesUsed: number;
  63274. primitivesCount: number
  63275. };
  63276. issues: {
  63277. messages: Array<string>;
  63278. numErrors: number;
  63279. numHints: number;
  63280. numInfos: number;
  63281. numWarnings: number;
  63282. truncated: boolean
  63283. };
  63284. mimeType: string;
  63285. uri: string;
  63286. validatedAt: string;
  63287. validatorVersion: string;
  63288. }
  63289. /**
  63290. * Interface for glTF validation options
  63291. */
  63292. interface IGLTFValidationOptions {
  63293. uri?: string;
  63294. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  63295. validateAccessorData?: boolean;
  63296. maxIssues?: number;
  63297. ignoredIssues?: Array<string>;
  63298. severityOverrides?: Object;
  63299. }
  63300. /**
  63301. * glTF validator object Tyyings
  63302. */
  63303. interface IGLTFValidatorTypings {
  63304. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  63305. }
  63306. declare module BABYLON {
  63307. /** @hidden */
  63308. export var cellPixelShader: {
  63309. name: string;
  63310. shader: string;
  63311. };
  63312. }
  63313. declare module BABYLON {
  63314. /** @hidden */
  63315. export var cellVertexShader: {
  63316. name: string;
  63317. shader: string;
  63318. };
  63319. }
  63320. declare module BABYLON {
  63321. export class CellMaterial extends BABYLON.PushMaterial {
  63322. private _diffuseTexture;
  63323. diffuseTexture: BABYLON.BaseTexture;
  63324. diffuseColor: BABYLON.Color3; computeHighLevel: boolean;
  63325. computeHighLevel: boolean;
  63326. private _disableLighting;
  63327. disableLighting: boolean;
  63328. private _maxSimultaneousLights;
  63329. maxSimultaneousLights: number;
  63330. private _renderId;
  63331. constructor(name: string, scene: BABYLON.Scene);
  63332. needAlphaBlending(): boolean;
  63333. needAlphaTesting(): boolean;
  63334. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63335. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63336. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63337. getAnimatables(): BABYLON.IAnimatable[];
  63338. getActiveTextures(): BABYLON.BaseTexture[];
  63339. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63340. dispose(forceDisposeEffect?: boolean): void;
  63341. getClassName(): string;
  63342. clone(name: string): CellMaterial;
  63343. serialize(): any;
  63344. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  63345. }
  63346. }
  63347. declare module BABYLON {
  63348. export class CustomShaderStructure {
  63349. FragmentStore: string;
  63350. VertexStore: string;
  63351. constructor();
  63352. }
  63353. export class ShaderSpecialParts {
  63354. constructor();
  63355. Fragment_Begin: string;
  63356. Fragment_Definitions: string;
  63357. Fragment_MainBegin: string;
  63358. Fragment_Custom_Diffuse: string;
  63359. Fragment_Before_Lights: string;
  63360. Fragment_Before_Fog: string;
  63361. Fragment_Custom_Alpha: string;
  63362. Fragment_Before_FragColor: string;
  63363. Vertex_Begin: string;
  63364. Vertex_Definitions: string;
  63365. Vertex_MainBegin: string;
  63366. Vertex_Before_PositionUpdated: string;
  63367. Vertex_Before_NormalUpdated: string;
  63368. Vertex_MainEnd: string;
  63369. }
  63370. export class CustomMaterial extends BABYLON.StandardMaterial {
  63371. static ShaderIndexer: number;
  63372. CustomParts: ShaderSpecialParts; isCreatedShader: boolean; createdShaderName: string; customUniform: string[]; newUniforms: string[]; newUniformInstances: any[]; newSamplerInstances: BABYLON.Texture[];
  63373. FragmentShader: string;
  63374. VertexShader: string;
  63375. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  63376. ReviewUniform(name: string, arr: string[]): string[];
  63377. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  63378. constructor(name: string, scene: BABYLON.Scene);
  63379. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  63380. Fragment_Begin(shaderPart: string): CustomMaterial;
  63381. Fragment_Definitions(shaderPart: string): CustomMaterial;
  63382. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  63383. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  63384. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  63385. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  63386. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  63387. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  63388. Vertex_Begin(shaderPart: string): CustomMaterial;
  63389. Vertex_Definitions(shaderPart: string): CustomMaterial;
  63390. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  63391. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  63392. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  63393. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  63394. }
  63395. }
  63396. declare module BABYLON {
  63397. export class ShaderAlebdoParts {
  63398. constructor();
  63399. Fragment_Begin: string;
  63400. Fragment_Definitions: string;
  63401. Fragment_MainBegin: string;
  63402. Fragment_Custom_Albedo: string;
  63403. Fragment_Before_Lights: string;
  63404. Fragment_Before_Fog: string;
  63405. Fragment_Custom_Alpha: string;
  63406. Fragment_Before_FragColor: string;
  63407. Vertex_Begin: string;
  63408. Vertex_Definitions: string;
  63409. Vertex_MainBegin: string;
  63410. Vertex_Before_PositionUpdated: string;
  63411. Vertex_Before_NormalUpdated: string;
  63412. Vertex_MainEnd: string;
  63413. }
  63414. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  63415. static ShaderIndexer: number;
  63416. CustomParts: ShaderAlebdoParts; isCreatedShader: boolean; createdShaderName: string; customUniform: string[]; newUniforms: string[]; newUniformInstances: any[]; newSamplerInstances: BABYLON.Texture[];
  63417. FragmentShader: string;
  63418. VertexShader: string;
  63419. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  63420. ReviewUniform(name: string, arr: string[]): string[];
  63421. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  63422. constructor(name: string, scene: BABYLON.Scene);
  63423. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  63424. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  63425. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  63426. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  63427. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  63428. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  63429. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  63430. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  63431. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  63432. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  63433. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  63434. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  63435. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  63436. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  63437. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  63438. }
  63439. }
  63440. declare module BABYLON {
  63441. /** @hidden */
  63442. export var firePixelShader: {
  63443. name: string;
  63444. shader: string;
  63445. };
  63446. }
  63447. declare module BABYLON {
  63448. /** @hidden */
  63449. export var fireVertexShader: {
  63450. name: string;
  63451. shader: string;
  63452. };
  63453. }
  63454. declare module BABYLON {
  63455. export class FireMaterial extends BABYLON.PushMaterial {
  63456. private _diffuseTexture;
  63457. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63458. private _distortionTexture;
  63459. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63460. private _opacityTexture;
  63461. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63462. diffuseColor: BABYLON.Color3;
  63463. speed: number;
  63464. private _scaledDiffuse;
  63465. private _renderId;
  63466. private _lastTime;
  63467. constructor(name: string, scene: BABYLON.Scene);
  63468. needAlphaBlending(): boolean;
  63469. needAlphaTesting(): boolean;
  63470. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63471. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63472. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63473. getAnimatables(): BABYLON.IAnimatable[];
  63474. getActiveTextures(): BABYLON.BaseTexture[];
  63475. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63476. getClassName(): string;
  63477. dispose(forceDisposeEffect?: boolean): void;
  63478. clone(name: string): FireMaterial;
  63479. serialize(): any;
  63480. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  63481. }
  63482. }
  63483. declare module BABYLON {
  63484. /** @hidden */
  63485. export var furPixelShader: {
  63486. name: string;
  63487. shader: string;
  63488. };
  63489. }
  63490. declare module BABYLON {
  63491. /** @hidden */
  63492. export var furVertexShader: {
  63493. name: string;
  63494. shader: string;
  63495. };
  63496. }
  63497. declare module BABYLON {
  63498. export class FurMaterial extends BABYLON.PushMaterial {
  63499. private _diffuseTexture;
  63500. diffuseTexture: BABYLON.BaseTexture;
  63501. private _heightTexture;
  63502. heightTexture: BABYLON.BaseTexture;
  63503. diffuseColor: BABYLON.Color3;
  63504. furLength: number;
  63505. furAngle: number;
  63506. furColor: BABYLON.Color3;
  63507. furOffset: number;
  63508. furSpacing: number;
  63509. furGravity: BABYLON.Vector3;
  63510. furSpeed: number;
  63511. furDensity: number;
  63512. furOcclusion: number;
  63513. furTexture: BABYLON.DynamicTexture;
  63514. private _disableLighting;
  63515. disableLighting: boolean;
  63516. private _maxSimultaneousLights;
  63517. maxSimultaneousLights: number;
  63518. highLevelFur: boolean; meshes: BABYLON.AbstractMesh[];
  63519. private _renderId;
  63520. private _furTime;
  63521. constructor(name: string, scene: BABYLON.Scene);
  63522. furTime: number;
  63523. needAlphaBlending(): boolean;
  63524. needAlphaTesting(): boolean;
  63525. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63526. updateFur(): void;
  63527. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63528. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63529. getAnimatables(): BABYLON.IAnimatable[];
  63530. getActiveTextures(): BABYLON.BaseTexture[];
  63531. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63532. dispose(forceDisposeEffect?: boolean): void;
  63533. clone(name: string): FurMaterial;
  63534. serialize(): any;
  63535. getClassName(): string;
  63536. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  63537. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  63538. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  63539. }
  63540. }
  63541. declare module BABYLON {
  63542. /** @hidden */
  63543. export var gradientPixelShader: {
  63544. name: string;
  63545. shader: string;
  63546. };
  63547. }
  63548. declare module BABYLON {
  63549. /** @hidden */
  63550. export var gradientVertexShader: {
  63551. name: string;
  63552. shader: string;
  63553. };
  63554. }
  63555. declare module BABYLON {
  63556. export class GradientMaterial extends BABYLON.PushMaterial {
  63557. private _maxSimultaneousLights;
  63558. maxSimultaneousLights: number;
  63559. topColor: BABYLON.Color3;
  63560. topColorAlpha: number;
  63561. bottomColor: BABYLON.Color3;
  63562. bottomColorAlpha: number;
  63563. offset: number;
  63564. scale: number;
  63565. smoothness: number;
  63566. private _disableLighting;
  63567. disableLighting: boolean;
  63568. private _renderId;
  63569. constructor(name: string, scene: BABYLON.Scene);
  63570. needAlphaBlending(): boolean;
  63571. needAlphaTesting(): boolean;
  63572. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63573. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63574. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63575. getAnimatables(): BABYLON.IAnimatable[];
  63576. dispose(forceDisposeEffect?: boolean): void;
  63577. clone(name: string): GradientMaterial;
  63578. serialize(): any;
  63579. getClassName(): string;
  63580. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  63581. }
  63582. }
  63583. declare module BABYLON {
  63584. /** @hidden */
  63585. export var gridPixelShader: {
  63586. name: string;
  63587. shader: string;
  63588. };
  63589. }
  63590. declare module BABYLON {
  63591. /** @hidden */
  63592. export var gridVertexShader: {
  63593. name: string;
  63594. shader: string;
  63595. };
  63596. }
  63597. declare module BABYLON {
  63598. /**
  63599. * The grid materials allows you to wrap any shape with a grid.
  63600. * Colors are customizable.
  63601. */
  63602. export class GridMaterial extends BABYLON.PushMaterial {
  63603. /**
  63604. * Main color of the grid (e.g. between lines)
  63605. */
  63606. mainColor: BABYLON.Color3;
  63607. /**
  63608. * Color of the grid lines.
  63609. */
  63610. lineColor: BABYLON.Color3;
  63611. /**
  63612. * The scale of the grid compared to unit.
  63613. */
  63614. gridRatio: number;
  63615. /**
  63616. * Allows setting an offset for the grid lines.
  63617. */
  63618. gridOffset: BABYLON.Vector3;
  63619. /**
  63620. * The frequency of thicker lines.
  63621. */
  63622. majorUnitFrequency: number;
  63623. /**
  63624. * The visibility of minor units in the grid.
  63625. */
  63626. minorUnitVisibility: number;
  63627. /**
  63628. * The grid opacity outside of the lines.
  63629. */
  63630. opacity: number;
  63631. /**
  63632. * Determine RBG output is premultiplied by alpha value.
  63633. */
  63634. preMultiplyAlpha: boolean;
  63635. private _opacityTexture;
  63636. opacityTexture: BABYLON.BaseTexture;
  63637. private _gridControl;
  63638. private _renderId;
  63639. /**
  63640. * constructor
  63641. * @param name The name given to the material in order to identify it afterwards.
  63642. * @param scene The scene the material is used in.
  63643. */
  63644. constructor(name: string, scene: BABYLON.Scene);
  63645. /**
  63646. * Returns wehter or not the grid requires alpha blending.
  63647. */
  63648. needAlphaBlending(): boolean;
  63649. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  63650. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63651. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63652. /**
  63653. * Dispose the material and its associated resources.
  63654. * @param forceDisposeEffect will also dispose the used effect when true
  63655. */
  63656. dispose(forceDisposeEffect?: boolean): void;
  63657. clone(name: string): GridMaterial;
  63658. serialize(): any;
  63659. getClassName(): string;
  63660. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  63661. }
  63662. }
  63663. declare module BABYLON {
  63664. /** @hidden */
  63665. export var lavaPixelShader: {
  63666. name: string;
  63667. shader: string;
  63668. };
  63669. }
  63670. declare module BABYLON {
  63671. /** @hidden */
  63672. export var lavaVertexShader: {
  63673. name: string;
  63674. shader: string;
  63675. };
  63676. }
  63677. declare module BABYLON {
  63678. export class LavaMaterial extends BABYLON.PushMaterial {
  63679. private _diffuseTexture;
  63680. diffuseTexture: BABYLON.BaseTexture;
  63681. noiseTexture: BABYLON.BaseTexture;
  63682. fogColor: BABYLON.Color3;
  63683. speed: number;
  63684. movingSpeed: number;
  63685. lowFrequencySpeed: number;
  63686. fogDensity: number;
  63687. private _lastTime;
  63688. diffuseColor: BABYLON.Color3;
  63689. private _disableLighting;
  63690. disableLighting: boolean;
  63691. private _unlit;
  63692. unlit: boolean;
  63693. private _maxSimultaneousLights;
  63694. maxSimultaneousLights: number;
  63695. private _scaledDiffuse;
  63696. private _renderId;
  63697. constructor(name: string, scene: BABYLON.Scene);
  63698. needAlphaBlending(): boolean;
  63699. needAlphaTesting(): boolean;
  63700. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63701. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63702. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63703. getAnimatables(): BABYLON.IAnimatable[];
  63704. getActiveTextures(): BABYLON.BaseTexture[];
  63705. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63706. dispose(forceDisposeEffect?: boolean): void;
  63707. clone(name: string): LavaMaterial;
  63708. serialize(): any;
  63709. getClassName(): string;
  63710. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  63711. }
  63712. }
  63713. declare module BABYLON {
  63714. /** @hidden */
  63715. export var mixPixelShader: {
  63716. name: string;
  63717. shader: string;
  63718. };
  63719. }
  63720. declare module BABYLON {
  63721. /** @hidden */
  63722. export var mixVertexShader: {
  63723. name: string;
  63724. shader: string;
  63725. };
  63726. }
  63727. declare module BABYLON {
  63728. export class MixMaterial extends BABYLON.PushMaterial {
  63729. /**
  63730. * Mix textures
  63731. */
  63732. private _mixTexture1;
  63733. mixTexture1: BABYLON.BaseTexture;
  63734. private _mixTexture2;
  63735. mixTexture2: BABYLON.BaseTexture;
  63736. /**
  63737. * Diffuse textures
  63738. */
  63739. private _diffuseTexture1;
  63740. diffuseTexture1: BABYLON.Texture;
  63741. private _diffuseTexture2;
  63742. diffuseTexture2: BABYLON.Texture;
  63743. private _diffuseTexture3;
  63744. diffuseTexture3: BABYLON.Texture;
  63745. private _diffuseTexture4;
  63746. diffuseTexture4: BABYLON.Texture;
  63747. private _diffuseTexture5;
  63748. diffuseTexture5: BABYLON.Texture;
  63749. private _diffuseTexture6;
  63750. diffuseTexture6: BABYLON.Texture;
  63751. private _diffuseTexture7;
  63752. diffuseTexture7: BABYLON.Texture;
  63753. private _diffuseTexture8;
  63754. diffuseTexture8: BABYLON.Texture;
  63755. /**
  63756. * Uniforms
  63757. */
  63758. diffuseColor: BABYLON.Color3;
  63759. specularColor: BABYLON.Color3;
  63760. specularPower: number;
  63761. private _disableLighting;
  63762. disableLighting: boolean;
  63763. private _maxSimultaneousLights;
  63764. maxSimultaneousLights: number;
  63765. private _renderId;
  63766. constructor(name: string, scene: BABYLON.Scene);
  63767. needAlphaBlending(): boolean;
  63768. needAlphaTesting(): boolean;
  63769. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63770. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63771. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63772. getAnimatables(): BABYLON.IAnimatable[];
  63773. getActiveTextures(): BABYLON.BaseTexture[];
  63774. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63775. dispose(forceDisposeEffect?: boolean): void;
  63776. clone(name: string): MixMaterial;
  63777. serialize(): any;
  63778. getClassName(): string;
  63779. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  63780. }
  63781. }
  63782. declare module BABYLON {
  63783. /** @hidden */
  63784. export var normalPixelShader: {
  63785. name: string;
  63786. shader: string;
  63787. };
  63788. }
  63789. declare module BABYLON {
  63790. /** @hidden */
  63791. export var normalVertexShader: {
  63792. name: string;
  63793. shader: string;
  63794. };
  63795. }
  63796. declare module BABYLON {
  63797. export class NormalMaterial extends BABYLON.PushMaterial {
  63798. private _diffuseTexture;
  63799. diffuseTexture: BABYLON.BaseTexture;
  63800. diffuseColor: BABYLON.Color3;
  63801. private _disableLighting;
  63802. disableLighting: boolean;
  63803. private _maxSimultaneousLights;
  63804. maxSimultaneousLights: number;
  63805. private _renderId;
  63806. constructor(name: string, scene: BABYLON.Scene);
  63807. needAlphaBlending(): boolean;
  63808. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  63809. needAlphaTesting(): boolean;
  63810. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63811. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63812. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63813. getAnimatables(): BABYLON.IAnimatable[];
  63814. getActiveTextures(): BABYLON.BaseTexture[];
  63815. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63816. dispose(forceDisposeEffect?: boolean): void;
  63817. clone(name: string): NormalMaterial;
  63818. serialize(): any;
  63819. getClassName(): string;
  63820. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  63821. }
  63822. }
  63823. declare module BABYLON {
  63824. /** @hidden */
  63825. export var shadowOnlyPixelShader: {
  63826. name: string;
  63827. shader: string;
  63828. };
  63829. }
  63830. declare module BABYLON {
  63831. /** @hidden */
  63832. export var shadowOnlyVertexShader: {
  63833. name: string;
  63834. shader: string;
  63835. };
  63836. }
  63837. declare module BABYLON {
  63838. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  63839. private _renderId;
  63840. private _activeLight;
  63841. constructor(name: string, scene: BABYLON.Scene);
  63842. shadowColor: BABYLON.Color3;
  63843. needAlphaBlending(): boolean;
  63844. needAlphaTesting(): boolean;
  63845. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63846. activeLight: BABYLON.IShadowLight;
  63847. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63848. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63849. clone(name: string): ShadowOnlyMaterial;
  63850. serialize(): any;
  63851. getClassName(): string;
  63852. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  63853. }
  63854. }
  63855. declare module BABYLON {
  63856. /** @hidden */
  63857. export var simplePixelShader: {
  63858. name: string;
  63859. shader: string;
  63860. };
  63861. }
  63862. declare module BABYLON {
  63863. /** @hidden */
  63864. export var simpleVertexShader: {
  63865. name: string;
  63866. shader: string;
  63867. };
  63868. }
  63869. declare module BABYLON {
  63870. export class SimpleMaterial extends BABYLON.PushMaterial {
  63871. private _diffuseTexture;
  63872. diffuseTexture: BABYLON.BaseTexture;
  63873. diffuseColor: BABYLON.Color3;
  63874. private _disableLighting;
  63875. disableLighting: boolean;
  63876. private _maxSimultaneousLights;
  63877. maxSimultaneousLights: number;
  63878. private _renderId;
  63879. constructor(name: string, scene: BABYLON.Scene);
  63880. needAlphaBlending(): boolean;
  63881. needAlphaTesting(): boolean;
  63882. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63883. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63884. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63885. getAnimatables(): BABYLON.IAnimatable[];
  63886. getActiveTextures(): BABYLON.BaseTexture[];
  63887. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63888. dispose(forceDisposeEffect?: boolean): void;
  63889. clone(name: string): SimpleMaterial;
  63890. serialize(): any;
  63891. getClassName(): string;
  63892. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  63893. }
  63894. }
  63895. declare module BABYLON {
  63896. /** @hidden */
  63897. export var skyPixelShader: {
  63898. name: string;
  63899. shader: string;
  63900. };
  63901. }
  63902. declare module BABYLON {
  63903. /** @hidden */
  63904. export var skyVertexShader: {
  63905. name: string;
  63906. shader: string;
  63907. };
  63908. }
  63909. declare module BABYLON {
  63910. /**
  63911. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  63912. * @see https://doc.babylonjs.com/extensions/sky
  63913. */
  63914. export class SkyMaterial extends BABYLON.PushMaterial {
  63915. /**
  63916. * Defines the overall luminance of sky in interval ]0, 1[.
  63917. */
  63918. luminance: number;
  63919. /**
  63920. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  63921. */
  63922. turbidity: number;
  63923. /**
  63924. * Defines the sky appearance (light intensity).
  63925. */
  63926. rayleigh: number;
  63927. /**
  63928. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  63929. */
  63930. mieCoefficient: number;
  63931. /**
  63932. * Defines the amount of haze particles following the Mie scattering theory.
  63933. */
  63934. mieDirectionalG: number;
  63935. /**
  63936. * Defines the distance of the sun according to the active scene camera.
  63937. */
  63938. distance: number;
  63939. /**
  63940. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  63941. * "inclined".
  63942. */
  63943. inclination: number;
  63944. /**
  63945. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  63946. * an object direction and a reference direction.
  63947. */
  63948. azimuth: number;
  63949. /**
  63950. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  63951. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  63952. */
  63953. sunPosition: BABYLON.Vector3;
  63954. /**
  63955. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  63956. * .sunPosition property.
  63957. */
  63958. useSunPosition: boolean;
  63959. /**
  63960. * Defines an offset vector used to get a horizon offset.
  63961. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  63962. */
  63963. cameraOffset: BABYLON.Vector3;
  63964. private _cameraPosition;
  63965. private _renderId;
  63966. /**
  63967. * Instantiates a new sky material.
  63968. * This material allows to create dynamic and texture free
  63969. * effects for skyboxes by taking care of the atmosphere state.
  63970. * @see https://doc.babylonjs.com/extensions/sky
  63971. * @param name Define the name of the material in the scene
  63972. * @param scene Define the scene the material belong to
  63973. */
  63974. constructor(name: string, scene: BABYLON.Scene);
  63975. /**
  63976. * Specifies if the material will require alpha blending
  63977. * @returns a boolean specifying if alpha blending is needed
  63978. */
  63979. needAlphaBlending(): boolean;
  63980. /**
  63981. * Specifies if this material should be rendered in alpha test mode
  63982. * @returns false as the sky material doesn't need alpha testing.
  63983. */
  63984. needAlphaTesting(): boolean;
  63985. /**
  63986. * Get the texture used for alpha test purpose.
  63987. * @returns null as the sky material has no texture.
  63988. */
  63989. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63990. /**
  63991. * Get if the submesh is ready to be used and all its information available.
  63992. * Child classes can use it to update shaders
  63993. * @param mesh defines the mesh to check
  63994. * @param subMesh defines which submesh to check
  63995. * @param useInstances specifies that instances should be used
  63996. * @returns a boolean indicating that the submesh is ready or not
  63997. */
  63998. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63999. /**
  64000. * Binds the submesh to this material by preparing the effect and shader to draw
  64001. * @param world defines the world transformation matrix
  64002. * @param mesh defines the mesh containing the submesh
  64003. * @param subMesh defines the submesh to bind the material to
  64004. */
  64005. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64006. /**
  64007. * Get the list of animatables in the material.
  64008. * @returns the list of animatables object used in the material
  64009. */
  64010. getAnimatables(): BABYLON.IAnimatable[];
  64011. /**
  64012. * Disposes the material
  64013. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  64014. */
  64015. dispose(forceDisposeEffect?: boolean): void;
  64016. /**
  64017. * Makes a duplicate of the material, and gives it a new name
  64018. * @param name defines the new name for the duplicated material
  64019. * @returns the cloned material
  64020. */
  64021. clone(name: string): SkyMaterial;
  64022. /**
  64023. * Serializes this material in a JSON representation
  64024. * @returns the serialized material object
  64025. */
  64026. serialize(): any;
  64027. /**
  64028. * Gets the current class name of the material e.g. "SkyMaterial"
  64029. * Mainly use in serialization.
  64030. * @returns the class name
  64031. */
  64032. getClassName(): string;
  64033. /**
  64034. * Creates a sky material from parsed material data
  64035. * @param source defines the JSON representation of the material
  64036. * @param scene defines the hosting scene
  64037. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  64038. * @returns a new sky material
  64039. */
  64040. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  64041. }
  64042. }
  64043. declare module BABYLON {
  64044. /** @hidden */
  64045. export var terrainPixelShader: {
  64046. name: string;
  64047. shader: string;
  64048. };
  64049. }
  64050. declare module BABYLON {
  64051. /** @hidden */
  64052. export var terrainVertexShader: {
  64053. name: string;
  64054. shader: string;
  64055. };
  64056. }
  64057. declare module BABYLON {
  64058. export class TerrainMaterial extends BABYLON.PushMaterial {
  64059. private _mixTexture;
  64060. mixTexture: BABYLON.BaseTexture;
  64061. private _diffuseTexture1;
  64062. diffuseTexture1: BABYLON.Texture;
  64063. private _diffuseTexture2;
  64064. diffuseTexture2: BABYLON.Texture;
  64065. private _diffuseTexture3;
  64066. diffuseTexture3: BABYLON.Texture;
  64067. private _bumpTexture1;
  64068. bumpTexture1: BABYLON.Texture;
  64069. private _bumpTexture2;
  64070. bumpTexture2: BABYLON.Texture;
  64071. private _bumpTexture3;
  64072. bumpTexture3: BABYLON.Texture;
  64073. diffuseColor: BABYLON.Color3;
  64074. specularColor: BABYLON.Color3;
  64075. specularPower: number;
  64076. private _disableLighting;
  64077. disableLighting: boolean;
  64078. private _maxSimultaneousLights;
  64079. maxSimultaneousLights: number;
  64080. private _renderId;
  64081. constructor(name: string, scene: BABYLON.Scene);
  64082. needAlphaBlending(): boolean;
  64083. needAlphaTesting(): boolean;
  64084. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64085. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64086. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64087. getAnimatables(): BABYLON.IAnimatable[];
  64088. getActiveTextures(): BABYLON.BaseTexture[];
  64089. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64090. dispose(forceDisposeEffect?: boolean): void;
  64091. clone(name: string): TerrainMaterial;
  64092. serialize(): any;
  64093. getClassName(): string;
  64094. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  64095. }
  64096. }
  64097. declare module BABYLON {
  64098. /** @hidden */
  64099. export var triplanarPixelShader: {
  64100. name: string;
  64101. shader: string;
  64102. };
  64103. }
  64104. declare module BABYLON {
  64105. /** @hidden */
  64106. export var triplanarVertexShader: {
  64107. name: string;
  64108. shader: string;
  64109. };
  64110. }
  64111. declare module BABYLON {
  64112. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  64113. mixTexture: BABYLON.BaseTexture;
  64114. private _diffuseTextureX;
  64115. diffuseTextureX: BABYLON.BaseTexture;
  64116. private _diffuseTextureY;
  64117. diffuseTextureY: BABYLON.BaseTexture;
  64118. private _diffuseTextureZ;
  64119. diffuseTextureZ: BABYLON.BaseTexture;
  64120. private _normalTextureX;
  64121. normalTextureX: BABYLON.BaseTexture;
  64122. private _normalTextureY;
  64123. normalTextureY: BABYLON.BaseTexture;
  64124. private _normalTextureZ;
  64125. normalTextureZ: BABYLON.BaseTexture;
  64126. tileSize: number;
  64127. diffuseColor: BABYLON.Color3;
  64128. specularColor: BABYLON.Color3;
  64129. specularPower: number;
  64130. private _disableLighting;
  64131. disableLighting: boolean;
  64132. private _maxSimultaneousLights;
  64133. maxSimultaneousLights: number;
  64134. private _renderId;
  64135. constructor(name: string, scene: BABYLON.Scene);
  64136. needAlphaBlending(): boolean;
  64137. needAlphaTesting(): boolean;
  64138. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64139. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64140. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64141. getAnimatables(): BABYLON.IAnimatable[];
  64142. getActiveTextures(): BABYLON.BaseTexture[];
  64143. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64144. dispose(forceDisposeEffect?: boolean): void;
  64145. clone(name: string): TriPlanarMaterial;
  64146. serialize(): any;
  64147. getClassName(): string;
  64148. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  64149. }
  64150. }
  64151. declare module BABYLON {
  64152. /** @hidden */
  64153. export var waterPixelShader: {
  64154. name: string;
  64155. shader: string;
  64156. };
  64157. }
  64158. declare module BABYLON {
  64159. /** @hidden */
  64160. export var waterVertexShader: {
  64161. name: string;
  64162. shader: string;
  64163. };
  64164. }
  64165. declare module BABYLON {
  64166. export class WaterMaterial extends BABYLON.PushMaterial {
  64167. renderTargetSize: BABYLON.Vector2;
  64168. private _bumpTexture;
  64169. bumpTexture: BABYLON.BaseTexture;
  64170. diffuseColor: BABYLON.Color3;
  64171. specularColor: BABYLON.Color3;
  64172. specularPower: number;
  64173. private _disableLighting;
  64174. disableLighting: boolean;
  64175. private _maxSimultaneousLights;
  64176. maxSimultaneousLights: number;
  64177. /**
  64178. * @param {number}: Represents the wind force
  64179. */
  64180. windForce: number;
  64181. /**
  64182. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  64183. */
  64184. windDirection: BABYLON.Vector2;
  64185. /**
  64186. * @param {number}: Wave height, represents the height of the waves
  64187. */
  64188. waveHeight: number;
  64189. /**
  64190. * @param {number}: Bump height, represents the bump height related to the bump map
  64191. */
  64192. bumpHeight: number;
  64193. /**
  64194. * @param {boolean}: Add a smaller moving bump to less steady waves.
  64195. */
  64196. private _bumpSuperimpose;
  64197. bumpSuperimpose: boolean;
  64198. /**
  64199. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  64200. */
  64201. private _fresnelSeparate;
  64202. fresnelSeparate: boolean;
  64203. /**
  64204. * @param {boolean}: bump Waves modify the reflection.
  64205. */
  64206. private _bumpAffectsReflection;
  64207. bumpAffectsReflection: boolean;
  64208. /**
  64209. * @param {number}: The water color blended with the refraction (near)
  64210. */
  64211. waterColor: BABYLON.Color3;
  64212. /**
  64213. * @param {number}: The blend factor related to the water color
  64214. */
  64215. colorBlendFactor: number;
  64216. /**
  64217. * @param {number}: The water color blended with the reflection (far)
  64218. */
  64219. waterColor2: BABYLON.Color3;
  64220. /**
  64221. * @param {number}: The blend factor related to the water color (reflection, far)
  64222. */
  64223. colorBlendFactor2: number;
  64224. /**
  64225. * @param {number}: Represents the maximum length of a wave
  64226. */
  64227. waveLength: number;
  64228. /**
  64229. * @param {number}: Defines the waves speed
  64230. */
  64231. waveSpeed: number;
  64232. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  64233. private _mesh;
  64234. private _refractionRTT;
  64235. private _reflectionRTT;
  64236. private _reflectionTransform;
  64237. private _lastTime;
  64238. private _lastDeltaTime;
  64239. private _renderId;
  64240. private _useLogarithmicDepth;
  64241. private _waitingRenderList;
  64242. /**
  64243. * Gets a boolean indicating that current material needs to register RTT
  64244. */
  64245. readonly hasRenderTargetTextures: boolean;
  64246. /**
  64247. * Constructor
  64248. */
  64249. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  64250. useLogarithmicDepth: boolean;
  64251. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  64252. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  64253. addToRenderList(node: any): void;
  64254. enableRenderTargets(enable: boolean): void;
  64255. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  64256. readonly renderTargetsEnabled: boolean;
  64257. needAlphaBlending(): boolean;
  64258. needAlphaTesting(): boolean;
  64259. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64260. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64261. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64262. private _createRenderTargets;
  64263. getAnimatables(): BABYLON.IAnimatable[];
  64264. getActiveTextures(): BABYLON.BaseTexture[];
  64265. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64266. dispose(forceDisposeEffect?: boolean): void;
  64267. clone(name: string): WaterMaterial;
  64268. serialize(): any;
  64269. getClassName(): string;
  64270. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  64271. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  64272. }
  64273. }
  64274. declare module BABYLON {
  64275. /** @hidden */
  64276. export var asciiartPixelShader: {
  64277. name: string;
  64278. shader: string;
  64279. };
  64280. }
  64281. declare module BABYLON {
  64282. /**
  64283. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  64284. *
  64285. * It basically takes care rendering the font front the given font size to a texture.
  64286. * This is used later on in the postprocess.
  64287. */
  64288. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  64289. private _font;
  64290. private _text;
  64291. private _charSize;
  64292. /**
  64293. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  64294. */
  64295. readonly charSize: number;
  64296. /**
  64297. * Create a new instance of the Ascii Art FontTexture class
  64298. * @param name the name of the texture
  64299. * @param font the font to use, use the W3C CSS notation
  64300. * @param text the caracter set to use in the rendering.
  64301. * @param scene the scene that owns the texture
  64302. */
  64303. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  64304. /**
  64305. * Gets the max char width of a font.
  64306. * @param font the font to use, use the W3C CSS notation
  64307. * @return the max char width
  64308. */
  64309. private getFontWidth;
  64310. /**
  64311. * Gets the max char height of a font.
  64312. * @param font the font to use, use the W3C CSS notation
  64313. * @return the max char height
  64314. */
  64315. private getFontHeight;
  64316. /**
  64317. * Clones the current AsciiArtTexture.
  64318. * @return the clone of the texture.
  64319. */
  64320. clone(): AsciiArtFontTexture;
  64321. /**
  64322. * Parses a json object representing the texture and returns an instance of it.
  64323. * @param source the source JSON representation
  64324. * @param scene the scene to create the texture for
  64325. * @return the parsed texture
  64326. */
  64327. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  64328. }
  64329. /**
  64330. * Option available in the Ascii Art Post Process.
  64331. */
  64332. export interface IAsciiArtPostProcessOptions {
  64333. /**
  64334. * The font to use following the w3c font definition.
  64335. */
  64336. font?: string;
  64337. /**
  64338. * The character set to use in the postprocess.
  64339. */
  64340. characterSet?: string;
  64341. /**
  64342. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  64343. * This number is defined between 0 and 1;
  64344. */
  64345. mixToTile?: number;
  64346. /**
  64347. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  64348. * This number is defined between 0 and 1;
  64349. */
  64350. mixToNormal?: number;
  64351. }
  64352. /**
  64353. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  64354. *
  64355. * Simmply add it to your scene and let the nerd that lives in you have fun.
  64356. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  64357. */
  64358. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  64359. /**
  64360. * The font texture used to render the char in the post process.
  64361. */
  64362. private _asciiArtFontTexture;
  64363. /**
  64364. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  64365. * This number is defined between 0 and 1;
  64366. */
  64367. mixToTile: number;
  64368. /**
  64369. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  64370. * This number is defined between 0 and 1;
  64371. */
  64372. mixToNormal: number;
  64373. /**
  64374. * Instantiates a new Ascii Art Post Process.
  64375. * @param name the name to give to the postprocess
  64376. * @camera the camera to apply the post process to.
  64377. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  64378. */
  64379. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  64380. }
  64381. }
  64382. declare module BABYLON {
  64383. /** @hidden */
  64384. export var digitalrainPixelShader: {
  64385. name: string;
  64386. shader: string;
  64387. };
  64388. }
  64389. declare module BABYLON {
  64390. /**
  64391. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  64392. *
  64393. * It basically takes care rendering the font front the given font size to a texture.
  64394. * This is used later on in the postprocess.
  64395. */
  64396. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  64397. private _font;
  64398. private _text;
  64399. private _charSize;
  64400. /**
  64401. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  64402. */
  64403. readonly charSize: number;
  64404. /**
  64405. * Create a new instance of the Digital Rain FontTexture class
  64406. * @param name the name of the texture
  64407. * @param font the font to use, use the W3C CSS notation
  64408. * @param text the caracter set to use in the rendering.
  64409. * @param scene the scene that owns the texture
  64410. */
  64411. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  64412. /**
  64413. * Gets the max char width of a font.
  64414. * @param font the font to use, use the W3C CSS notation
  64415. * @return the max char width
  64416. */
  64417. private getFontWidth;
  64418. /**
  64419. * Gets the max char height of a font.
  64420. * @param font the font to use, use the W3C CSS notation
  64421. * @return the max char height
  64422. */
  64423. private getFontHeight;
  64424. /**
  64425. * Clones the current DigitalRainFontTexture.
  64426. * @return the clone of the texture.
  64427. */
  64428. clone(): DigitalRainFontTexture;
  64429. /**
  64430. * Parses a json object representing the texture and returns an instance of it.
  64431. * @param source the source JSON representation
  64432. * @param scene the scene to create the texture for
  64433. * @return the parsed texture
  64434. */
  64435. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  64436. }
  64437. /**
  64438. * Option available in the Digital Rain Post Process.
  64439. */
  64440. export interface IDigitalRainPostProcessOptions {
  64441. /**
  64442. * The font to use following the w3c font definition.
  64443. */
  64444. font?: string;
  64445. /**
  64446. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  64447. * This number is defined between 0 and 1;
  64448. */
  64449. mixToTile?: number;
  64450. /**
  64451. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  64452. * This number is defined between 0 and 1;
  64453. */
  64454. mixToNormal?: number;
  64455. }
  64456. /**
  64457. * DigitalRainPostProcess helps rendering everithing in digital rain.
  64458. *
  64459. * Simmply add it to your scene and let the nerd that lives in you have fun.
  64460. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  64461. */
  64462. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  64463. /**
  64464. * The font texture used to render the char in the post process.
  64465. */
  64466. private _digitalRainFontTexture;
  64467. /**
  64468. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  64469. * This number is defined between 0 and 1;
  64470. */
  64471. mixToTile: number;
  64472. /**
  64473. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  64474. * This number is defined between 0 and 1;
  64475. */
  64476. mixToNormal: number;
  64477. /**
  64478. * Instantiates a new Digital Rain Post Process.
  64479. * @param name the name to give to the postprocess
  64480. * @camera the camera to apply the post process to.
  64481. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  64482. */
  64483. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  64484. }
  64485. }
  64486. declare module BABYLON {
  64487. /** @hidden */
  64488. export var oceanPostProcessPixelShader: {
  64489. name: string;
  64490. shader: string;
  64491. };
  64492. }
  64493. declare module BABYLON {
  64494. /**
  64495. * Option available in the Ocean Post Process.
  64496. */
  64497. export interface IOceanPostProcessOptions {
  64498. /**
  64499. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  64500. */
  64501. reflectionSize?: number | {
  64502. width: number;
  64503. height: number;
  64504. } | {
  64505. ratio: number;
  64506. };
  64507. /**
  64508. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  64509. */
  64510. refractionSize?: number | {
  64511. width: number;
  64512. height: number;
  64513. } | {
  64514. ratio: number;
  64515. };
  64516. }
  64517. /**
  64518. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  64519. *
  64520. * Simmply add it to your scene and let the nerd that lives in you have fun.
  64521. * Example usage:
  64522. * var pp = new OceanPostProcess("myOcean", camera);
  64523. * pp.reflectionEnabled = true;
  64524. * pp.refractionEnabled = true;
  64525. */
  64526. export class OceanPostProcess extends BABYLON.PostProcess {
  64527. /**
  64528. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  64529. */
  64530. /**
  64531. * Sets weither or not the real-time reflection is enabled on the ocean.
  64532. * Is set to true, the reflection mirror texture will be used as reflection texture.
  64533. */
  64534. reflectionEnabled: boolean;
  64535. /**
  64536. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  64537. */
  64538. /**
  64539. * Sets weither or not the real-time refraction is enabled on the ocean.
  64540. * Is set to true, the refraction render target texture will be used as refraction texture.
  64541. */
  64542. refractionEnabled: boolean;
  64543. /**
  64544. * Gets wether or not the post-processes is supported by the running hardware.
  64545. * This requires draw buffer supports.
  64546. */
  64547. readonly isSupported: boolean;
  64548. /**
  64549. * This is the reflection mirror texture used to display reflections on the ocean.
  64550. * By default, render list is empty.
  64551. */
  64552. reflectionTexture: BABYLON.MirrorTexture;
  64553. /**
  64554. * This is the refraction render target texture used to display refraction on the ocean.
  64555. * By default, render list is empty.
  64556. */
  64557. refractionTexture: BABYLON.RenderTargetTexture;
  64558. private _time;
  64559. private _cameraRotation;
  64560. private _cameraViewMatrix;
  64561. private _reflectionEnabled;
  64562. private _refractionEnabled;
  64563. private _geometryRenderer;
  64564. /**
  64565. * Instantiates a new Ocean Post Process.
  64566. * @param name the name to give to the postprocess.
  64567. * @camera the camera to apply the post process to.
  64568. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  64569. */
  64570. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  64571. /**
  64572. * Returns the appropriate defines according to the current configuration.
  64573. */
  64574. private _getDefines;
  64575. /**
  64576. * Computes the current camera rotation as the shader requires a camera rotation.
  64577. */
  64578. private _computeCameraRotation;
  64579. }
  64580. }
  64581. declare module BABYLON {
  64582. /** @hidden */
  64583. export var brickProceduralTexturePixelShader: {
  64584. name: string;
  64585. shader: string;
  64586. };
  64587. }
  64588. declare module BABYLON {
  64589. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  64590. private _numberOfBricksHeight;
  64591. private _numberOfBricksWidth;
  64592. private _jointColor;
  64593. private _brickColor;
  64594. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64595. updateShaderUniforms(): void;
  64596. numberOfBricksHeight: number;
  64597. numberOfBricksWidth: number;
  64598. jointColor: BABYLON.Color3;
  64599. brickColor: BABYLON.Color3;
  64600. /**
  64601. * Serializes this brick procedural texture
  64602. * @returns a serialized brick procedural texture object
  64603. */
  64604. serialize(): any;
  64605. /**
  64606. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  64607. * @param parsedTexture defines parsed texture data
  64608. * @param scene defines the current scene
  64609. * @param rootUrl defines the root URL containing brick procedural texture information
  64610. * @returns a parsed Brick Procedural BABYLON.Texture
  64611. */
  64612. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  64613. }
  64614. }
  64615. declare module BABYLON {
  64616. /** @hidden */
  64617. export var cloudProceduralTexturePixelShader: {
  64618. name: string;
  64619. shader: string;
  64620. };
  64621. }
  64622. declare module BABYLON {
  64623. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  64624. private _skyColor;
  64625. private _cloudColor;
  64626. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64627. updateShaderUniforms(): void;
  64628. skyColor: BABYLON.Color4;
  64629. cloudColor: BABYLON.Color4;
  64630. /**
  64631. * Serializes this cloud procedural texture
  64632. * @returns a serialized cloud procedural texture object
  64633. */
  64634. serialize(): any;
  64635. /**
  64636. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  64637. * @param parsedTexture defines parsed texture data
  64638. * @param scene defines the current scene
  64639. * @param rootUrl defines the root URL containing cloud procedural texture information
  64640. * @returns a parsed Cloud Procedural BABYLON.Texture
  64641. */
  64642. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  64643. }
  64644. }
  64645. declare module BABYLON {
  64646. /** @hidden */
  64647. export var fireProceduralTexturePixelShader: {
  64648. name: string;
  64649. shader: string;
  64650. };
  64651. }
  64652. declare module BABYLON {
  64653. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  64654. private _time;
  64655. private _speed;
  64656. private _autoGenerateTime;
  64657. private _fireColors;
  64658. private _alphaThreshold;
  64659. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64660. updateShaderUniforms(): void;
  64661. render(useCameraPostProcess?: boolean): void;
  64662. static readonly PurpleFireColors: BABYLON.Color3[];
  64663. static readonly GreenFireColors: BABYLON.Color3[];
  64664. static readonly RedFireColors: BABYLON.Color3[];
  64665. static readonly BlueFireColors: BABYLON.Color3[];
  64666. autoGenerateTime: boolean;
  64667. fireColors: BABYLON.Color3[];
  64668. time: number;
  64669. speed: BABYLON.Vector2;
  64670. alphaThreshold: number;
  64671. /**
  64672. * Serializes this fire procedural texture
  64673. * @returns a serialized fire procedural texture object
  64674. */
  64675. serialize(): any;
  64676. /**
  64677. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  64678. * @param parsedTexture defines parsed texture data
  64679. * @param scene defines the current scene
  64680. * @param rootUrl defines the root URL containing fire procedural texture information
  64681. * @returns a parsed Fire Procedural BABYLON.Texture
  64682. */
  64683. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  64684. }
  64685. }
  64686. declare module BABYLON {
  64687. /** @hidden */
  64688. export var grassProceduralTexturePixelShader: {
  64689. name: string;
  64690. shader: string;
  64691. };
  64692. }
  64693. declare module BABYLON {
  64694. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  64695. private _grassColors;
  64696. private _groundColor;
  64697. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64698. updateShaderUniforms(): void;
  64699. grassColors: BABYLON.Color3[];
  64700. groundColor: BABYLON.Color3;
  64701. /**
  64702. * Serializes this grass procedural texture
  64703. * @returns a serialized grass procedural texture object
  64704. */
  64705. serialize(): any;
  64706. /**
  64707. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  64708. * @param parsedTexture defines parsed texture data
  64709. * @param scene defines the current scene
  64710. * @param rootUrl defines the root URL containing grass procedural texture information
  64711. * @returns a parsed Grass Procedural BABYLON.Texture
  64712. */
  64713. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  64714. }
  64715. }
  64716. declare module BABYLON {
  64717. /** @hidden */
  64718. export var marbleProceduralTexturePixelShader: {
  64719. name: string;
  64720. shader: string;
  64721. };
  64722. }
  64723. declare module BABYLON {
  64724. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  64725. private _numberOfTilesHeight;
  64726. private _numberOfTilesWidth;
  64727. private _amplitude;
  64728. private _jointColor;
  64729. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64730. updateShaderUniforms(): void;
  64731. numberOfTilesHeight: number;
  64732. amplitude: number;
  64733. numberOfTilesWidth: number;
  64734. jointColor: BABYLON.Color3;
  64735. /**
  64736. * Serializes this marble procedural texture
  64737. * @returns a serialized marble procedural texture object
  64738. */
  64739. serialize(): any;
  64740. /**
  64741. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  64742. * @param parsedTexture defines parsed texture data
  64743. * @param scene defines the current scene
  64744. * @param rootUrl defines the root URL containing marble procedural texture information
  64745. * @returns a parsed Marble Procedural BABYLON.Texture
  64746. */
  64747. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  64748. }
  64749. }
  64750. declare module BABYLON {
  64751. /** @hidden */
  64752. export var normalMapProceduralTexturePixelShader: {
  64753. name: string;
  64754. shader: string;
  64755. };
  64756. }
  64757. declare module BABYLON {
  64758. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  64759. private _baseTexture;
  64760. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64761. updateShaderUniforms(): void;
  64762. render(useCameraPostProcess?: boolean): void;
  64763. resize(size: any, generateMipMaps: any): void;
  64764. baseTexture: BABYLON.Texture;
  64765. /**
  64766. * Serializes this normal map procedural texture
  64767. * @returns a serialized normal map procedural texture object
  64768. */
  64769. serialize(): any;
  64770. /**
  64771. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  64772. * @param parsedTexture defines parsed texture data
  64773. * @param scene defines the current scene
  64774. * @param rootUrl defines the root URL containing normal map procedural texture information
  64775. * @returns a parsed Normal Map Procedural BABYLON.Texture
  64776. */
  64777. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  64778. }
  64779. }
  64780. declare module BABYLON {
  64781. /** @hidden */
  64782. export var perlinNoiseProceduralTexturePixelShader: {
  64783. name: string;
  64784. shader: string;
  64785. };
  64786. }
  64787. declare module BABYLON {
  64788. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  64789. time: number;
  64790. timeScale: number;
  64791. translationSpeed: number;
  64792. private _currentTranslation;
  64793. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64794. updateShaderUniforms(): void;
  64795. render(useCameraPostProcess?: boolean): void;
  64796. resize(size: any, generateMipMaps: any): void;
  64797. /**
  64798. * Serializes this perlin noise procedural texture
  64799. * @returns a serialized perlin noise procedural texture object
  64800. */
  64801. serialize(): any;
  64802. /**
  64803. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  64804. * @param parsedTexture defines parsed texture data
  64805. * @param scene defines the current scene
  64806. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  64807. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  64808. */
  64809. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  64810. }
  64811. }
  64812. declare module BABYLON {
  64813. /** @hidden */
  64814. export var roadProceduralTexturePixelShader: {
  64815. name: string;
  64816. shader: string;
  64817. };
  64818. }
  64819. declare module BABYLON {
  64820. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  64821. private _roadColor;
  64822. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64823. updateShaderUniforms(): void;
  64824. roadColor: BABYLON.Color3;
  64825. /**
  64826. * Serializes this road procedural texture
  64827. * @returns a serialized road procedural texture object
  64828. */
  64829. serialize(): any;
  64830. /**
  64831. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  64832. * @param parsedTexture defines parsed texture data
  64833. * @param scene defines the current scene
  64834. * @param rootUrl defines the root URL containing road procedural texture information
  64835. * @returns a parsed Road Procedural BABYLON.Texture
  64836. */
  64837. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  64838. }
  64839. }
  64840. declare module BABYLON {
  64841. /** @hidden */
  64842. export var starfieldProceduralTexturePixelShader: {
  64843. name: string;
  64844. shader: string;
  64845. };
  64846. }
  64847. declare module BABYLON {
  64848. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  64849. private _time;
  64850. private _alpha;
  64851. private _beta;
  64852. private _zoom;
  64853. private _formuparam;
  64854. private _stepsize;
  64855. private _tile;
  64856. private _brightness;
  64857. private _darkmatter;
  64858. private _distfading;
  64859. private _saturation;
  64860. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64861. updateShaderUniforms(): void;
  64862. time: number;
  64863. alpha: number;
  64864. beta: number;
  64865. formuparam: number;
  64866. stepsize: number;
  64867. zoom: number;
  64868. tile: number;
  64869. brightness: number;
  64870. darkmatter: number;
  64871. distfading: number;
  64872. saturation: number;
  64873. /**
  64874. * Serializes this starfield procedural texture
  64875. * @returns a serialized starfield procedural texture object
  64876. */
  64877. serialize(): any;
  64878. /**
  64879. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  64880. * @param parsedTexture defines parsed texture data
  64881. * @param scene defines the current scene
  64882. * @param rootUrl defines the root URL containing startfield procedural texture information
  64883. * @returns a parsed Starfield Procedural BABYLON.Texture
  64884. */
  64885. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  64886. }
  64887. }
  64888. declare module BABYLON {
  64889. /** @hidden */
  64890. export var woodProceduralTexturePixelShader: {
  64891. name: string;
  64892. shader: string;
  64893. };
  64894. }
  64895. declare module BABYLON {
  64896. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  64897. private _ampScale;
  64898. private _woodColor;
  64899. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64900. updateShaderUniforms(): void;
  64901. ampScale: number;
  64902. woodColor: BABYLON.Color3;
  64903. /**
  64904. * Serializes this wood procedural texture
  64905. * @returns a serialized wood procedural texture object
  64906. */
  64907. serialize(): any;
  64908. /**
  64909. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  64910. * @param parsedTexture defines parsed texture data
  64911. * @param scene defines the current scene
  64912. * @param rootUrl defines the root URL containing wood procedural texture information
  64913. * @returns a parsed Wood Procedural BABYLON.Texture
  64914. */
  64915. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  64916. }
  64917. }